3

rebol 中的 do 函数似乎可以接受无限的参数。我可以用我自己的函数(不使用参数块)来做到这一点吗?

4

2 回答 2

3

无法定义具有可变数量参数的函数。此 Rebol 邮件列表线程http://www.rebol.org/ml-display-thread.r?m=rmlDTXB中的最后一条消息有解释。

do 函数也接受一个参数:

>> ? 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.
于 2009-09-14T15:34:59.723 回答
2

你是对的,在 REBOL 中有可变参数函数,一个例子是 DO 函数。在 R2 中,甚至 MAKE 函数也是可变参数的。然而,函数规范方言不允许您定义自己的可变参数函数,甚至没有计划这样的功能。

于 2010-07-25T09:18:02.767 回答