Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!julius.cs.uiuc.edu!usc!samsung!munnari.oz.au!uniwa!fennel.cc.uwa.oz.au!a_dent From: a_dent@fennel.cc.uwa.oz.au Newsgroups: comp.sys.mac.programmer Subject: Re: Another THINK Pascal gotcha - "With" instance vars Message-ID: <1991Jan29.021127.2840@fennel.cc.uwa.oz.au> Date: 28 Jan 91 18:11:27 GMT References: <1991Jan25.233122.2825@fennel.cc.uwa.oz.au> <1991Jan25.234200.7536@santra.uucp> Organization: University of Western Australia Lines: 42 In article <1991Jan25.234200.7536@santra.uucp>, jmunkki@hila.hut.fi (Juri Munkki) writes: > In article <1991Jan25.233122.2825@fennel.cc.uwa.oz.au> a_dent@fennel.cc.uwa.oz.au writes: >>"with" and may be quite small (depending on what you call). However, even >>if you don't call things that move memory, the presence of networking drivers >>such as Tops can cause memory moves inside ANY sequence of code. > > Most of us know that this is not true. It might be true of TOPS (I never > liked that product, so it's easy to convince me that it has bugs in it), > but in general drivers and other interrupt level routines do not move > memory manager blocks. You have to call a toolbox routine (and not just > any routine, although nowadays it's considered bad style to assume that > some routines do not move memory) to cause a change in memory manager > structures. This was my opinion. Nevertheless, it moves!! Anyway, I'm unlikely to have the hours to sit and watch the heap and Heisenberg would probably get in the way. Is there anyway a request to extend the System Heap could be caused by TOPS and consequently affect the Application heap? > > Even Inside Macintosh warns Pascal programmers about "with", so it really > shouldn't be a gotcha. It's just a common bug. Use a heap scrambler along > with discipline to find the bugs. I know about "with" and the dangers of handles etc. The big point was that you can take some perfectly safe code (using "with" on structures that are local variables) and if you put it into an Object Pascal method, operating on instance variables, it is suddenly dangerous. I think it is more dangerous than passing instance variables as VAR parameters, because the "with" window of vulnerability is so much smaller and so it is harder to track down. I'd really like to see these two problems caught by the compiler, I can't see it being too hard a job to parse :-|) (hopeful big "cheesy grin", Rich). > > ____________________________________________________________________________ > / Juri Munkki / Helsinki University of Technology / Wind / Project / > / jmunkki@hut.fi / Computing Center Macintosh Support / Surf / STORM / > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Andy Dent A.D. Software phone 09 249 2719 Mac & VAX programmer 94 Bermuda Dve, Ballajura a_dent@fennel.cc.uwa.oz Western Australia 6066 a_dent@fennel.cc.uwa.oz.AU (international)