You can use local words by asking for it (cf example at the bottom) with
/local un the argument block or with a USE inside the body... so it's
possible to avoid side effects.

The way a language treat "locality" is just a choice. In PHP, variables are
all locals to function... unless you ask them to be "global". In rebol it's
the opposite. It should't be a problem since we know the way it work. It's
certainly less difficult to understand for the begginer than the
(any-blocks) words vs standard variables behavior.


Renaud


>> a: func [a /local b][z: b: a]
>>
>> a 1.618
== 1.618
>>
>> z
== 1.618
>>
>> b
** Script Error: b has no value
** Near: b
>>
>> a
** Script Error: a is missing its a argument
** Near: a


----- Original Message -----
From: "Jussi Hagman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 25, 2001 1:39 AM
Subject: [REBOL] Q: Functions and the visibility of words


> Hi,
>
> I have been playing with REBOL for a some time but I still am curious
> about the word visibility scheme chosen by Carl.
>
> When a word is definied inside a function it is visible also outside the
> function (after the invication of the function) unless explicitly
> specified local. This seems to be a different approach to most of the
> other programming languages (at least that I know :).
>
> The disadvantages are obvious, it is easy for the programmer to
> introduce unwanted side-effects, but what are the advantages this scheme
> introduces?
>
>
> --
> Jussi Hagman                                CS in �bo Akademi University
> Studentbyn 4 D 33                           [EMAIL PROTECTED]
> 20540 �bo                                   [EMAIL PROTECTED]
> Finland
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>
>

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to