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

[REBOL] Suspected bug Re:

From: galtbarber:mailandnews at: 11-Aug-2000 18:30

when you do something like this: foreach someword someseries [ print someword ] then someword is set to the values of someseries, but only within the code block of the foreach loop. I think there is a new context created for the foreach invocation, and in that context the value of someword is indeed repeatedly set to each element of someseries. Notice that you won't be able to see someword outside the foreach loop before or after it, although you may be able to see something if someword has a value in the enclosing, possibly global context. This is actually a good feature of rebol, I like it. In other languages like c, pascal, or basic, you can see the looping variables value after the function executes, and in large software you have to worry about clobbering some other variable. But here you know that whatever word you choose to use with foreach will only be redefined within the code block, and not anywhere else. Now, doindx1 is defined much earlier, and it has a code block which when created will have find initial to be a local variable of the run function, so that is what is bound there inside doindx1 when the function creation is evaluated. To do what you want, you would have to move doindx1 down into the foreach loop, or else pass it as a parameter, or else don't use foreach, or else use some other global variable. -Galt