From: [EMAIL PROTECTED] (Ingo Hohmann)
.. on default global variables [EMAIL PROTECTED] spoketh thus:
The disadvantages are so major, that something needs
to be done.
And here are two things I've come up with ...
snip
From: [EMAIL PROTECTED] (Andrew Martin)
2. I've gotten into the habit of
[EMAIL PROTECTED]:
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 :).
Colin wrote:
2. I've gotten into the habit of starting all functions like this:
myfunc: func [ /local aa bb cc dd]
Why not get Rebol do the work for you?
Fun: function [
Automatic local word generation for a function. [catch]
Spec [block!]{Optional help info followed by arg
... on default global variables [EMAIL PROTECTED] spoketh thus:
The disadvantages are so major, that something needs to be done.
And here are two things I've come up with ...
context: func [
Defines a unique (underived) object. *patched* (iho)
blk [block!] Object variables and values.
Ursprüngliche Nachricht
Am 26.04.01, 06:02:32, schrieb [EMAIL PROTECTED] zum Thema [REBOL] Re:
Q: Functions and the visibility of words:
[EMAIL PROTECTED]:
When a word is definied inside a function it is visible also outside
the
function (after the invication of the function
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
] Re: Q: Functions and the visibility of words
Jussi Hagman wrote:
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
Jussi Hagman wrote:
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
First think about this: Using rebol, I use far fewer temporary variables.
In fact I can write vast amounts of code without using them at all. So it
is not a big loss.
As far as unwanted side effects, this depends on the particular scheme you
use for accessing non-local words. For instance,