Re: scope of variables

new topic     » goto parent     » topic index » view thread      » older message » newer message
jaygade said...
useless said...

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu