[EMAIL PROTECTED] wrote:

> 1.  What are the `correct' rules for function application,
>     variable scoping, and objects?

They're amazingly simple, at least in my speculation. I'll try to
explain them briefly because I have too little time now...

When you create a function, REBOL creates a (static) context,
containing the function's parameters etc. Then the body of the
function is bound to that context. (Some magic happens for
recursive functions, I'll return on this the next time...). When
the function is called, the actual parameters are assigned to the
formal parameters in the function's context.

Every word contains a reference to a context (parhaps also a
reference to a value). When the intepreter evaluates a word, it
follows that reference and searchs there for its value.

Objects are just contexts.

> 2.  Are these rules useful?

Yes.

> 3.  Is the current *implementation* of REBOL faithfully following
>     these rules?

Yes. (Well, I created the rules looking at the implementation...)

> 4.  Is the *next* implementation of REBOL likely to behave
>     differently?

I don't think so.

> The current implementation seems to be fairly well behaved as long
> as you don't attempt to return functions outside of the scope in
> which they are defined.

I don't understand what you are saying here, sorry.

>  However, functions aren't
> first-class objects if you can't return them
> as values.  

They are, and you can. Trust me. :-)

> Every version of REBOL has either made subtle or drastic changes in
> how variables are scoped.

That's false. It never changed, if not from 1.0 to 2.0 (EVERYTHING
changed...).

> If there are `correct' rules for function application, variable
> scoping, and objects, why is REBOL Tech. so adamant about keeping
> them secret?

They do not have the time. Do realize that they're not a big
company.

> Is the GC buggy when it collects contexts or do contexts have a
> limitied lifetime?

There's a bug. Contexts have undefinite extent.

> Jeff's code doesn't work in this case:
> 
>    funny-func:  composite
>                     func [x] [x + 1]
>                     func [y] [y * 2]

That's just because it requires words, not functions, as
arguments. Change it to:

composite: func [f g][func [x] compose [(:f) (:g) x]]

and it will work.

Ciao,
    /Gabriele./
o--------------------) .-^-. (----------------------------------o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC     \ \-\_/-/ /  http://www.amyresource.it/AGI/ |
o--------------------) `-v-' (----------------------------------o

Reply via email to