Re: scope of variables
- Posted by useless Jan 01, 2011
- 2626 views
Gosh, you can declare junk[1..5000] and prolly not run out of nested "decision block" junk[x], and you have the feature that all the junk is available outside that level too.
useless
I don't know what you mean.
atom junk = 12.7 procedure foo() -- untested, caveats apply! integer x = 100 sequence junk = {} for something = 1 to x do junk &= {} -- now i can use junk[x] -- it's a different junk[] each iteration -- it's saved for use later -- or i can erase it at any time -- it can hold anything -- blah -- blarg end for end procedure -- foo()
The way i understood Turbo Pascal handled procedures and functions, each was pretty much a new program by itself, inheriting variable scope and file handles and such from the main() it was nested in.
I did enjoy being able to nest procedures and functions inside other procedures and functions to limit scope or increase modularity. Euphoria still does not do this. I asked for it years ago. But much like your request to be able to declare variables willy-nilly, in Euphoria i merely make a new include to achieve these goals.
useless