Hi,
just a little misunderstanding:
Bind modifies it's argument, while Bind/copy doesn't modify the argument and
should be used like this:
result: bind/copy block word
Ladislav
> Don't know if you tried this, Joel, but here's a few more interesting
> lines to add to your example.
>
> >> a: 1
> == 1
> >> b: 2
> == 2
> >> e: [a b c]
> == [a b c]
> >> print e
> ** Script Error: c has no value.
> ** Where: c
> >> f: func [n /local c][c: n bind e 'c print e]
> >> f
> ** Script Error: f is missing its n argument.
> ** Where: f
> >> f 99
> 1 2 99
> >> print e
> 1 2 99
> >> bind e 'e
> == [a b c]
> >> print e
> ** Script Error: c has no value.
> ** Where: c
> ; (more)
> >> f 99
> 1 2 99
> >> print e
> 1 2 99
> ; 'c is restored to the 'e context
> >> c: 12
> >> bind e 'e
> == [a b c]
> >> print e
> >> 1 2 12
> ; 'e binds to 'c in the this context
> >> unset 'c
> >> print e
> ** Script Error: c has no value.
> ** Where: c
> ; no 'c in this context now
> >> f 99
> 1 2 99
> >> print e
> 1 2 99
> >> bind/copy e 'e
> == [a b c]
> >> print e
> 1 2 99
> ; with the copy refinement, 'e binds to the 'c in the 'f local context.
> >>f 98
> 1 2 98
> >>print e
> 1 2 98
> ; and when the 'c in the the 'f local context changes, so does the 'c
> in the 'e local context
> >>a: 65
> 65
> >>print e
> 65 2 98
> ; and we are still bound to the orignal 'a
>
> So to retain a word set to a value in a local context, we can use the
> 'bind/copy refinement.
>
> At first, I was thinking we were copying the 'c from the 'f context.
> But I guess we're really copying the 'c from the 'e context. Bind is
> operating in the block outside of 'e and so 'c does not exist to it.
> But I guess the /copy refinement recreates the local 'c so that bind
> can use it. It doesn't seem to be a "copy" in the usual sense though,
> since it appears to be the same value first created in 'f.
>
> Just as a value can be shared between words, perhaps a word can be
> shared among contexts.
>
> -Ted.
>
>
>
>