[REBOL] Re: sorting a serie ....
From: maximo:meteorstudios at: 19-Jun-2003 12:07
ah, but here you can stumble upon a very bad proble... one that took me a few days to
understand.
using compose will bind the word at that time.
if you just try this:
lbls: ["a" "b" "c"]
gblval: "YIPpE!"
vidblk: copy []
foreach lbl lbls [
append vidblk 'button
append vidblk lbl
append/only vidblk [
print [lbl gblval]
probe [lbl gblval] ]
]
gblval: "DAMN IT!"
probe vidblk
view layout vidblk
pressing on any button, will actually always print "c DAMN IT!"
lbls: ["a" "b" "c"]
gblval: "YIPpE!"now try this:
vidblk: copy []
foreach lbl lbls [
append vidblk 'button
append vidblk lbl
append/only vidblk reduce [
'print [lbl gblval]
'probe [lbl gblval]
]
]
gblval: "DAMN IT"
probe vidblk
view layout vidblk
pressing on any button, will actually always print "c DAMN IT!"
----------------------
NOW THE RIGHT ONE!!!
----------------------
lbls: ["a" "b" "c"]
gblval: "YIPpE!"now try this:
vidblk: copy []
foreach lbl lbls [
append vidblk 'button
append vidblk lbl
append/only vidblk compose/deep [
print "---global ref--"
print [(lbl) gblval]
probe [(lbl) gblval]=09
print "---local ref--" =09
print [(lbl) (gblval)]
probe [(lbl) (gblval)]
print ""
]
]
gblval: "DAMN IT"
probe vidblk
view layout vidblk
notice that in this example, gblval still stays a word with no value, because it was
never evaluated before the print (
-max
-----------
meteor Studios, T.D.
-----------
Strong enough for a man, but made for a woman