Brian, /local revelation! Thanks!
So, you really can see that when invoked,
/local is normally set to none, and
all "optional switch params" following it,
up to the next /switch if any, are set to none also.
Somehow I never realized that MULTIPLE parameters
can follow a /switch in the function definition
so I thought that /local was doing something special
allowing multiples, and that it had to come last.
So, you could use any [parma parmb /local x /morefrickinlocals s t u]
and s t u are locals that are just every bit as good as /local,
and it doesn't even matter if /local is the last switch, right?
The only limit is that all real params have to come
before the first /switch.
What did this save RT? Did they get to avoid having
to use 'use inside the function to create a separate
context frame with the locals local? Since they
had to support the /switches anyway and they had
a mechanism for that, why not bag the extra 'use
and stick the locals as "unused" switch parms?
was their thinking, I suppose.
The one change they had to make to accept this
is that /local unused switch params (local vars) are set to
none like any other unused switch parms
(since /local itself is not usually invoked)
This is different than simply returning false when queried
with value? which is how a 'use context works
and how you treat global variables as well.
So then locals became initialized to none rather
than simply being unset values.
This is kind of amusing:
>> g: func [][probe local ]
>> g
** Script Error: local has no value.
** Where: probe local
>> g: function [][][probe local ]
>> g
none
== none
>>
-Galt
p.s. Andrew, do you think of the
processor for make object! [ a: blah b: blahblah ]
as another dialect? That argument seems a teensy
bit stronger than function-as-dialect, but
what do I know?
-----------------
>
>Actually, the word local is bound to the function as well.
>/local is just another refinement - it's just treated in a
>special way by the help function. The evaluator doesn't
>treat it in a special way. You can preset locals like this:
>
> >> f: func [a /local b] [add a any [b 1]]
> >> f/local 1 3
>== 4
>
>I don't know about you, but I found this quite amusing. All
>those earnest REBOL programmers thinking /local is special,
>when it's really just a quick, elegant hack.
>
>I love this language :-)
>
>Brian Hawley