Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: func args by ladislav

From: rotenca:telvia:it at: 16-Oct-2001 17:47

Hi Ladislav,
> Hi Romano, > > I don't think, I must change your mind, but there is a difference you
Don't worry!
> probably don't see.
I hope. A new thing to learn.
> It is possible to define a Rebol function (a FUNCTION! > datatype value to be exact), that takes one argument and evaluates it: > > do-f-0: func [f] [ > f > ] > > 1) DO-F-0 is able to evaluate any zero-argument function supplied as the F > argument. > 2) DO-F-0 is unable to evaluate any one-or-more-argument function supplied > as the F argument > > Similarly it is possible to define a function that takes two arguments and > evaluates the first one supplying it the second one as its argument: > > do-f-1: func [f arg1] [ > f :arg1 > ] > > do-f-2: func [f arg1 arg2] [ > f :arg1 :arg2 > ] > > etc. > > 3) I think, that we are in agreement, how many arguments the above defined > functions take. It is evident, that for a Rebol function to evaluate its F > argument, the function must take n + 1 arguments, where n is the number of > arguments of F.
Upto here, we agree. Functions have a fixed number of args. Right?
> 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?
I don't understand. If the answer is no, functions have always a fixed number of args, like i think. You think that this is false. So, you should be able to write this kind of function. Right? My answer should be: no. Only if i have a pointer to the block in which my function has been called i could emulate the interpreter and count the argument taken by f and its following args. I could try with do/next or with a deep analysys of spec of function. It should be a problem to resolve infix/prefix op. But perhaps i have not understood your point.
> Cheers > Ladislav
P.S. I'm almost sure: the datatype simbol! is created every time a new bound or not bound word is added to the system. --- Ciao Romano