Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!ncar!ames!ucsd!ucsdhub!hp-sdd!ncr-sd!ncrlnk!uunet!mcvax!ukc!tcdcs!tcdmath!pcraig From: pcraig@maths.tcd.ie (Peter Craig) Newsgroups: comp.sys.mac.programmer Subject: Re: Object Pascal Keywords: Object Pascal Message-ID: <394@maths.tcd.ie> Date: 3 Feb 89 10:57:06 GMT References: <7096@spool.cs.wisc.edu> Reply-To: pcraig@maths.tcd.ie (Peter Craig) Organization: Maths Dept., Trinity College, Dublin Lines: 39 In article <7096@spool.cs.wisc.edu> engber@shorty.cs.wisc.edu (Mike Engber) writes: >Doyle wrote an articl on object Pascal in which he warns that using the >with statement on objects is dangerous in the same way using a with >statement on an unlocked handle is dangerous. This is because object >variables are really handles. (made to syntactically resemble normal ............... > >Also, for similar reasons Doyle warns against using an object's field as >a var parameter. The language definition seems to allow it, if it is a >problem then I have the same complaint again. > If you use MPW Object Pascal on the Mac, the allocation system for objects is under your control. You can change the routine which allocates objects. It goes by the name %OBNEW or some such thing. The 'object' still must be a handle to the data area, but it need not be a Macintosh Memory Manager handle. Specifically it need not be relocatable, or you could arrange for objects to be relocatable only during a garbage collect routine which you would run at 'safe' times. I had to get into this because I wished to have a very large number of objects for a statistical graphics application. Each data point is a separate object. Unfortunately the Mac Memory Manager gets very upset if you allocate too many separate blocks of memory and the machine then runs very slowly. Most, but not all, of the objects in my program are descendants of TFunnyObject (my own class) which behaves exactly like TObject except the allocation is done differently. This has worked very successfully. The only problem is that I have been rather lazy since I have sufficient memory and I haven't really bothered to write stuff to allow memory compaction etc. However it should be pretty easy to do, if I ever need to do it. Your difficulty above arises from confusing handles with relocatable handles, which is understandable given that the basic reason for using handles in the first place is to allow some of them to be relocatable. Peter Craig Peter Craig, Dept. of Statistics, Trinity College, Dublin 2, Ireland 353-1-772941 (x. 2048 or 1203) pcraig@maths.tcd.ie