[REBOL] Re: Dumb newbie Rebol question
From: maarten:vrijheid at: 5-Sep-2003 7:42
> >> use [x_a] [
> [ x_a: 123
> [ x: make object! [
> [ a: does [x_a]
> [ ]
> [ ]
> >> probe x
>
> make object! [
> a: func [][x_a]
> ]
> >> x/a
> == 123
> >> x_a
> ** Script Error: x_a has no value
> ** Near: x_a
>
> Note that 'x_a and it's value are not (easily) accessible outside the
> object. This kind of thing can be helpful in making only one of a
thing,
> by making the value of 'x_a an object! inside the object referred to
by
> 'x.
This trick is creating an anonymous 'use context that can be useful to
create the equivalent of a hidden stack frame and thus manipulate how
the interpreter reacts to some stuff.
For example, bot Ladislav and I have implemented tail recursion
eleminiation exactly the same using a use [ ..... ][ .... func [ ] []]
construct.
And there is your singleton!
Use [ single x10 ][ single: no func [][either single [ x10][x10:
some-new-object single:yes]]
--Maarten