[REBOL] Re: what to do with bind ?/an example
From: rebol665:ifrance at: 26-Nov-2001 13:07
Hi,
Thank you Tim. Your program is simple enough to make me get it. I have added
a new object function, without the binding. As expected the X outside the
object was modified.
I'am very grateful to the rebol-list and my skills improves step by step.
REBOL[]
x: "five"
obj: make object! [
x: 5
modify: func[arg[block!]][do bind arg 'self]
new-modify: func[arg[block!]][do arg ]
]
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
print {now let's use obj/new-modify without binding}
obj/new-modify [x: 15]
print join "This is x outside of the object: " x
print join "This is x inside of the object: " obj/x
halt
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
now let's use obj/new-modify without binding
This is x outside of the object: 15
This is x inside of the object: 10