Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: R: Re: Variable not avilable out of a foreach

From: tim-johnsons:web at: 10-Dec-2007 17:12

On Monday 10 December 2007, Giuseppe Chillemi wrote:
> > > The script returns LINE has no Value, I must assign it to a > > > > temporary > > > > > variable... why ? > > > > try changing get_data to a func and pass 'line as an > > argument to it tim > > Yes, it is another solution but my question is WHY is this happening ?
Hi Giuseppe: Because the source of get_data is first evaluated outside of the *scope* of the foreach loop. When it is called within the loop it treats 'line as a global which does not exist. If there were a global 'line, then you could have some very unpredictable results... See my second post on this question, I've got some little examples there. HTH Tim