Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!snorkelwacker.mit.edu!bloom-beacon!eru!kth.se!cyklop.nada.kth.se!news From: d88-jwa@byse.nada.kth.se (Jon W{tte) Newsgroups: comp.sys.mac.programmer Subject: Re: Why won't ResError return the right message? Message-ID: Date: 9 May 91 11:47:59 GMT References: <1696@babcock.cerc.wvu.wvnet.edu> <1991May6.143630.30448@kuhub.cc.ukans.edu> <13382@goofy.Apple.COM> <12946@pt.cs.cmu.edu> <13404@goofy.Apple.COM> Sender: news@nada.kth.se (Mr News) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 24 In-reply-to: REEKES@applelink.apple.com's message of 8 May 91 17:56:31 GMT In article <13404@goofy.Apple.COM> REEKES@applelink.apple.com (Jim Reekes) writes: > #define goodHand(x) ((x) && *(x)) A problem with goodHand above is that if the GetResource fails, then you may end up dereferencing a nil address. It will happen with Pascal's AND expression, but not with MPW Pascal's &. It all depends on the language's implementation. It's safe to just check on the handle Well, the example was in C, and C structly specifies lazy evaluation of logical expressions (like &&) unless you set ResLoad to false and the resource isn't in memory. BUT... if you set ResLoad to false (which is a valid thing to do) then goodHand above will always report an error! If you call SetResLoad(false) you probably know what you do, it's not a call to call lightly (and certain portions of the OS & toolbox will fail with SetResLoad(false)) -- Jon W{tte h+@nada.kth.se - Power !