Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!munnari.oz.au!uniwa!andreww From: andreww@uniwa.uwa.oz (Andrew John Williams) Newsgroups: comp.sys.mac.programmer Subject: Re: Another THINK Pascal gotcha - "With" instance vars Message-ID: <1991Feb6.060512.12890@uniwa.uwa.oz> Date: 6 Feb 91 06:05:12 GMT References: <1.27ACFB10@mmug.edgar.mn.org> Organization: University of Western Australia Lines: 31 Jim.Spencer@p510.f22.n282.z1.mmug.edgar.mn.org (Jim Spencer) writes: >Lawson English writes in a message to All >KR> myPtr := myHandle^; myValue := myPtr^; >KR> You don't have to worry about anything - including drivers - >KR> moving memory in between those two statements. >LE> Correction: you SHOULDN'T have to worry about anything moving >LE> memory between those two statements. Remember to drive defensively... >Huh? I don't profess to have anywhere near the knowledge of Keith but it sure looks to me like his statement is correct and the programmer shouldn't have to lose a moments sleep over this. I don't even start to understand why you won't want to waste time "driving defensively" in this situation. Locking and unlocking myHandle in this circumstance goes beyond careful: its downright wasteful. >If you are automatically, without thinking locking everything down before you dereference it, you are simply wasting both your customers' and your time. This may not be as bad as the guy here who said he never locked his handles down but its not good practice. > >-- >Jim Spencer - via The Minnesota Macintosh Users Group UUCP-Fido Gateway >UUCP: ...uunet!tcnet!kksys!edgar!mmug!22.510!Jim.Spencer >INET: Jim.Spencer@p510.f22.n282.z1.mmug.edgar.mn.or What happens if some program running in the background chooses that moment to do some memory shuffling? Goodbye handle. Remember John's three rules of Mac programming - 1) Always set your grafports 2) Always lock your handles 3) Buy a decent keyboard John West (stealing Andrew's account) I am NOT a fish, I am NOT a fish g