At 01:02 PM 10/25/99 +0000, you wrote:
>After playing around, I think here is a terminal session that shows how
>to "make sure" the arguments are used locally.
Hi,
1. You do not "need to make sure" that they are local. Anything declared in
the argument block is local.
2. If you wish to use a "use context" to localize words you do it two ways:
use [x y z] [
;- x y z are local from here ...
f: func [] [
]
] ;- ... to here
f: func [] [
use [x y z] [ ;- x y z are local within the function only, from here
do-something
] ;- ... to here only
]
Note however that there is a subtle different between the use of a "use
context" to localize words vs. using arguments or local words (which are
both local):
RULES:
1. Words declared in a use context are not accessable until they are
explicitly assigned a value:
f: func [] [
use [x] [
print value? 'x
]
]
>> f
false
f prints false because x has not been created! Let's create x:
f: func [] [
use [x] [
x: 1
print value? 'x
]
]
No f prints true:
>> f
true
In contrast, when I declare arguments local using /local
f: func [/local x] [
print value? 'x
]
REBOL returns true, even though I haven't assigned any value to x:
>> f
true
Here the fact that the local word was declared is sufficient to bring that
word into existence.
Tkae Care,
Elan
>
>>> use [ src text.align alt ] [ display|image: make function! [ src
>text.align alt ]
>[ [ rejoin [ {<IMG SRC="} src {" Align=} text.align { ALT="}
>alt {">} ] ] ]
>>> display|image http://www.fargonews.com/mac.jpg "center" "Internet
>Startup Kit"
>== {<IMG SRC="http://www.fargonews.com/mac.jpg" Align=center ALT=
>"Internet Startup Kit">}
>>> src: 1
>== 1
>>> text.align: 2
>== 2
>>> alt: 3
>== 3
>>> display|image http://www.fargonews.com/mac.jpg "center" "Internet
>Startup Kit"
>== {<IMG SRC="http://www.fargonews.com/mac.jpg" Align=center ALT=
>"Internet Startup Kit">}
>>> print src
>1
>>> print text.align
>2
>>> print alt
>3
>>>
>
>
>