[REBOL] Re: func args by ladislav
From: lmecir:mbox:vol:cz at: 17-Oct-2001 23:19
Hi Romano,
> Hi, Ladislav,
>
> Now i've thinked a little about the 'do mistery.
>
> > 4) Can you write a Rebol function (a FUNCTION! datatype value) able to
> > evaluate any F (i.e. F with any number of arguments) without cheating,
i.e.
> > without "packing" the arguments into a block?
>
> No. And RT also. I think that it is impossible to write a function which
read
> an unlimited number of arguments without a pointer to the line in which
> arguments can be found.
I am sorry that I succeeded to use a confusing terminology above. What I
really meant was to say, that even a one-argument taking function can "take"
an "unlimited" number of arguments, if your code "prepares" the arguments as
follows:
args: reduce [:arg1 :arg2]
f args
You would probably agree, that in this case F (formally) takes only one
argument.
> 1) RT "cheats". In the sense that it gives to the function 'do an hidden
arg
> which points to the executed line (the pointer used by the interpreter).
That would not be the same as above, because it still ensures, that DO can
take as many arguments as it needs.
> 2) In expressions like:
>
> do :- 1 2
>
> 'do sends to the interpreter a signal which say "evaluate the next value
(the
> 'do arg) in a special mode", a sort of flag for the interpreter.
Because DO is native, the distinction simply depends on a decision which
code is considered a part of DO and which isn't.
> 3) Mecir can explain to me how to pass an unlimited number of arguments
to a
> function without "cheating".
TOP SECRET :-)
> For what you know, the behaviour of 'do can be found in other fuctions
too?
I think, that the MAKE function behaves similarly as DO, because the number
of arguments it takes depends on the arguments. The only difference is, that
the number is limited in the case of MAKE.