Article View: comp.lang.misc
Article #5247Re: Var scoping in Wirth-type languages (was: Poor Algorithms)
From: Lawrence Crowl
Date: Thu, 10 Mar 1988 16:36
Date: Thu, 10 Mar 1988 16:36
23 lines
1739 bytes
1739 bytes
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
Technical Details
Message-ID:
<7562@sol.ARPA>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!bbn!rochester!crowlReferences:
<3821@ihlpf.ATT.COM> <2791@enea.se> <3949@ihlpf.ATT.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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