>myfunc: func [][ > localvar:: $25 > myinnerfunc: func [][ > innerlocal:: $10 > print localvar ; prints $25 > ] > print innerlocal; error! > ] > print localvar ; error! > > using the "::" for local var will make it more > convienient to create local vars (which i use all the > time over global vars). In addition, it will help > prevent some errors of accidental global var creation > because it is now easy to spot a local var. Best of
You can already do something like: myfunc: func [][ context [ localvar: $25 myinnerfunc: func [][ context [ innerlocal: $10 print localvar ; prints $25 ] ] print innerlocal; error! ] ] print localvar ; error! --- Ciao Romano ----- Original Message ----- From: "Rishi Oswal" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, April 24, 2002 5:08 AM Subject: [REBOL] local vars in functions > One part of REBOL that can feel odd is when i have to > define local variables of a function in the first > block of the function. I find it a bit annoying to > have to add new variables to the list for every little > local variable I use. In addition, I feel it clutters > up the first block and increases function size. In > addition, the way it is currently done could make it > easy to create hard to detect bugs. > > What I would like to see is another shortcut to > creating local variables in any context (function, > innerfunction, loop). The obvious way I see of doing > this is as follows: > > > myfunc: func [][ > localvar:: $25 > myinnerfunc: func [][ > innerlocal:: $10 > print localvar ; prints $25 > ] > print innerlocal; error! > ] > print localvar ; error! > > using the "::" for local var will make it more > convienient to create local vars (which i use all the > time over global vars). In addition, it will help > prevent some errors of accidental global var creation > because it is now easy to spot a local var. Best of > all, this type of shortcut would not break anything in > rebol. You could even use this in a loop: > > for count 1 10 1 [ > localvar:: "hello" > ] > > Using the "::" shortcut in a global context would be > the same as using a ":". > > The disadvantage I see is that it adds another thing > to the language.. But consider that now we could stop > using the /local keyword, reduce bugs, and use it > consistently everywhere, overall it can simplify > things. > > Anybody have other reasons as to why it was not done > this way?? > > Perhaps there is a performance issue?? > > rishi > > __________________________________________________ > Do You Yahoo!? > Yahoo! Games - play chess, backgammon, pool and more > http://games.yahoo.com/ > -- > To unsubscribe from this list, please send an email to > [EMAIL PROTECTED] with "unsubscribe" in the > subject, without the quotes. > -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.