Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Burroughs Large Systems
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== How programs map to the stack === Here is an example of how programs map to the stack structure '''begin''' β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β This is lexical level 2 (level zero is reserved for the operating system and level 1 for code segments). β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β At level 2 we place global variables for our program. '''integer''' ''i'', ''j'', ''k''; '''real''' ''f'', ''g''; '''array''' ''a'' [0:9]; '''procedure''' ''p'' ('''real''' ''p1'', ''p2''); '''value''' ''p1''; β p1 passed by value, p2 implicitly passed by reference. '''begin''' β β β β β β β β β β β β β β β β β β β This block is at lexical level 3 β β β β β β β β β β β β β β β β β β '''real''' ''r1'', ''r2'';<br /> ''r2'' := ''p1'' * ''5''; ''p2'' := ''r2''; β This sets ''g'' to the value of ''r2'' ''p1'' := ''r2''; β This sets ''p1'' to ''r2'', but not ''f'' β Since this overwrites the original value of ''f'' in ''p1'' it ''might'' be a β coding mistake. Some few of ALGOL's successors therefore insist that β value parameters be read only β but most do not. '''if''' ''r2'' > ''10'' '''then''' '''begin''' β β β β β β β β β β β β β β β β β β β β β β β β β β β β β A variable declared here makes this lexical level 4 β β β β β β β β β β β β β β β β β β β β β β β β β β β β '''integer''' ''n'';<br /> β The declaration of a variable makes this a block, which will invoke some β stack building code. Normally you won't declare variables here, in which β case this would be a compound statement, not a block. ... <== sample stack is executing somewhere here. '''end'''; '''end'''; ..... ''p'' (''f'', ''g''); '''end'''. Each stack frame corresponds to a lexical level in the current execution environment. As you can see, lexical level is the static textual nesting of a program, not the dynamic call nesting. The visibility rules of ALGOL, a language designed for single pass compilers, mean that only variables declared before the current position are visible at that part of the code, thus the requirement for forward declarations. All variables declared in enclosing blocks are visible. Another case is that variables of the same name may be declared in inner blocks and these effectively hide the outer variables which become inaccessible. Lexical nesting is static, unrelated to execution nesting with recursion, etc. so it is very rare to find a procedure nested more than five levels deep, and it could be argued that such programs would be poorly structured. B5000 machines allow nesting of up to 32 levels. This could cause difficulty for some systems that generated Algol source as output (tailored to solve some special problem) if the generation method frequently nested procedure within procedure.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)