Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!husc6!cmcl2!acf5!sabbagh From: sabbagh@acf5.NYU.EDU (sabbagh) Newsgroups: comp.sys.mac.programmer Subject: Re: HandleObject vs. 5+ meg of RAM and Virtual Memory Message-ID: <1220@acf5.NYU.EDU> Date: 18 Aug 90 17:55:48 GMT References: <279@unf7.UUCP> Reply-To: sabbagh@acf5.UUCP () Organization: New York University Lines: 57 In article <279@unf7.UUCP> shite@unf7.UUCP (Stephen Hite) writes: > > If I have 5 or 8 meg of RAM and virtual memory (a.k.a System 7.0.2 :-)) >is it really *worth* the limitations of using HandleObject? Some of limitations >are (as taken from the MPW C++ Beta Manual): > > 1. You can't "...declare global variables, local variables, arrays, members, > or parameters of handle-based types (rather than pointers to them)." > > 2. You can't use multiple inheritance (as discussed previously ad nauseum). > > 3. "It is not possible to allocate an array of handle-based objects, for > example, new MyObjects[10]." > > 4. You cannot "...take a pointer to a field of an indirect class (i.e., > &x->y). This restriction includes the implicit use of pointers by ref- > erences, such as int& p = x->y." > > [stuff deleted]. More thought would have revealed that these restrictions are quite reasonable. What is a HandleObject? It is an object that is intended to be allocated from the Mac heap! These are referenced using handles, which allows the Memory manager to deal with fragmentation, etc. Suppose you were writing code in C, Pascal, or any other language besides C++. Can you allocate handle objects as global or local variables, arrays, members or parameters of handle-based objects? NO, you can only manipulate pointers to them! Can you allocate an array of handle-based objects? No, you would need an array of handles to point to them (which you CAN do). Basically, HandleObject alleviates you from dealing with 1) dereferencing issues when dealing with the heap and 2) knowing which Toolbox calls move memory. So, my $0.02: 1) Use HandleObjects for things you would ordinarily allocate from the heap in another language. It will alleviate a number of programming issues unique to the Macintosh. 2) Don't use HandleObjects for things you would want as variables, array items, etc. I wouldn't make a Point class a HandleObject. Note that you can still use the heap for these other object classes, but you have to manage them yourself. Hadil G. Sabbagh E-mail: sabbagh@csd27.nyu.edu Voice: (212) 998-3125 Snail: Courant Institute of Math. Sci. 251 Mercer St. New York,NY 10012 "'He was killed by the usual cabal: by himself, first of all; by the woman he knew; by the woman he did not know; by the man who granted his inmost wish; and by the inevitable fifth, who was keeper of his conscience and keeper of the stone.'" -R. Davies, "Fifth Business"