[REBOL] Re: what to do with bind ?/an example
From: tim::johnsons-web::com at: 25-Nov-2001 17:54
Here's a REALLY simple illustration of what 'bind can do.
<wink>It took something this simple for me to understand it</wink>
REBOL[]
x: "five"
obj: make object! [x: 5
modify: func[arg[block!]][do bind arg 'self]
]
print join "This is x outside of the object: " x
print join "This is x inside of the object: " obj/x
print {now let's use obj/modify which is "bound" to "obj"}
obj/modify [x: 10]
print join "This is x outside of the object: " x
print join "This is x inside of the object: " obj/x
produces:
This is x outside of the object: five
This is x inside of the object: 5
now let's use obj/modify which is "bound" to "obj"
This is x outside of the object: five
This is x inside of the object: 10
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.johnsons-web.com