tags:

views:

76

answers:

2

The do function in rebol seems to accept unlimited arguments. Can I do that with my own function (without using a block of arguments) ?

+3  A: 

It is not possible to define a function with a variable number of arguments. The last message in this Rebol Mailing List thread http://www.rebol.org/ml-display-thread.r?m=rmlDTXB has an explanation.

Also the do function takes a single argument:

>> ? do
USAGE:
    DO value /args arg /next 

DESCRIPTION:
     Evaluates a block, file, URL, function, word, or any other value.
     DO is a native value.

ARGUMENTS:
     value -- Normally a file name, URL, or block (Type: any)

REFINEMENTS:
     /args -- If value is a script, this will set its system/script/args
         arg -- Args passed to a script. Normally a string. (Type: any)
     /next -- Do next expression only.  Return block with result and new position.
Peter W A Wood
+1  A: 

You are right, that in REBOL there are variadic functions, an example being the DO function. In R2, even the MAKE function is variadic. Nevertheless, the function specification dialect does not allow you to define your own variadic function, and such a feature isn't even planned.

Ladislav
Rebol is supposed to be more "expressive" than other languages so it's frustrating not to be able to do so or to have optional parameters. C#4 now at least has realized this http://davidhayden.com/blog/dave/archive/2009/06/02/CSharp4OptionalNamedParameters.aspxI'm not a designer of rebol, I'm just a user but as a user I know what I really need to be productive and this is one of the stuff I look forward too.Or at least it should be possible to hook the console to build our own handling of syntax but that's not either possible.
Rebol Tutorial
Console is a gem in rebol, it's also a pity one cannot easily customize it with some hooks that what make wordpress a success - though wordpress is not a programming language I mean the principle is a key.
Rebol Tutorial
It is an error to compare REBOL <code>f 1 2 3</code> to e.g. C <code>f(1, 2, 3)</code>. In fact, if you use a similarly complicated syntax as in C, you can do whatever you want in REBOL, using the <code>f [1 2 3]</code>, which in REBOL is actually only a unary call, no matter how many "arguments" you put into the block.Using this syntax you can easily find out, that you actually have much higher expressivity than in C, since neither order, quantity, nor any other "argument property" is limited.
Ladislav
it's 4 KEYPRESS with the 2 hands to do so :) This is most important in accessibility issue when you use the console as end-user GUI.
Rebol Tutorial
I am not using the console to write my REBOL scripts. I am using some text editors for that purpose instead.
Ladislav
And, I am quite curious, which keyboard layout you are using, taking into account, that your note does not apply to the US layout.
Ladislav