Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!kth.se!cyklop.nada.kth.se!news From: d88-jwa@dront.nada.kth.se (Jon W{tte) Newsgroups: comp.sys.mac.programmer Subject: Re: Double dereferenced handles Message-ID: <1991Feb1.160826.19760@nada.kth.se> Date: 1 Feb 91 16:08:26 GMT References: <1991Jan30.215459.7730@umiami.ir.miami.edu> Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 44 In article <> gv9b2c9z@umiami.ir.miami.edu (Ordinary Man) writes: >Is it bad programming practice to double dereference a handle to a record No, if it's only an assignment, I prefer this way. > HLock(Handle(theList)); > temp:=theList^; > temp^.item:=whatever; > HLock(Handle(theList)); > theList^^.item:=whatever; >Or does it matter? Not by much. If you don't like temp variables cluttering the declarations, you know what way to go... (Oh, and you mught be tempted to use the dereferenced handle later if it's hanging around in a pointer...) btw, you don't have to lock the handle if all you do with it is assignment, AND THE R.H.S. EXPRESSION DOESN'T MOVE MEMORY. Floating-point moves memory, as does trap calls. Simple math doesn't move memory. i.e. WindowRecord * * myWHandle = NewHandle ( sizeof ( WindowRecord ) ) ; /* Error checking &c ... */ * * myWHandle = * thePort ; /* This is legal without locking the handle ! */ >Thanks in advance, You're welcome, h+ :::::::: Jon W{tte, Stockholm, Sweden, h+@nada.kth.se :::::::: "The IM-IV file manager chapter documents zillions of calls, all of which seem to do almost the same thing and none of which seem to do what I want them to do." -- Juri Munkki (jmunkki@hut.fi) in comp.sys.mac.programmer