[REBOL] Re: Passing word in a block as an argument
From: greggirwin:mindspring at: 9-Feb-2003 21:55
TJ> I'd like to be able to initialize a block of words,
TJ> pass that block to a function and then get the values
TJ> in the words by referencing the names of the words.
The words are bound to the context of the FOREACH block so your other
code can't see them. If you just declare them at the top of your script,
so they're global, it will prevent the error. E.g.
a: b: c: d: none
But it still isn't looking at the values for the words as bound to the
FOREACH loop. If you define your function inside your loop, it will
work, but that's probably not what you want to do. :) E.g.
blk: [1 2 3 4 5 6 7 8 9 10 11 12]
cols: [a b c d]
foreach :cols blk [
test: func [e[block!]] [
print get 'a
?? a ?? b ?? c ?? d
test bind cols 'self
Beyond that, my poor tired brain isn't aware of a simple solution for
binding to the loop context. I'm sure someone else will chime in and
show us both how easy it is. :)