Path: utzoo!mnetor!uunet!husc6!bbn!rochester!crowl From: crowl@cs.rochester.edu (Lawrence Crowl) Newsgroups: comp.lang.misc Subject: Re: Var scoping in Wirth-type languages (was: Poor Algorithms) Message-ID: <7562@sol.ARPA> Date: 10 Mar 88 16:36:59 GMT References: <3821@ihlpf.ATT.COM> <2791@enea.se> <3949@ihlpf.ATT.COM> Reply-To: crowl@cs.rochester.edu (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 23 In article <3949@ihlpf.ATT.COM> nevin1@ihlpf.UUCP (00704a-Liber,N.J.) writes: [access to variables outside the current scope] >For every level deep that a variable is used after it is declared, one climb >up the static chain of activation records is required to access the variable >(this is due to the possibility of recursion). An alternative technique for accessing these variables is "display registers". Essentially, you have a register pointing to the current activation record for each level of nesting. No pointer chasing is required. For more details, see a compilers text. In most modern architectures, access to local variables is no more expensive than access to global variables. For local variables, access is via a small offset off the frame pointer (or one of the display registers). For global variables, access is via an absolute address. Since absolute addresses require more storage to encode, they often take more time to execute. Even when global variables are more efficient, the gain in efficiency is often not worth the loss in program clarity. -- Lawrence Crowl 716-275-9499 University of Rochester crowl@cs.rochester.edu Computer Science Department ...!{allegra,decvax,rutgers}!rochester!crowl Rochester, New York, 14627