解释器中的Perl 6函数参数语法(REPL)

lis*_*tor 4 arguments function perl6

解释器中的参数语法似乎存在一些不一致之处.我正在使用最新的Rakudo.请参阅以下终端输出:

$ perl6
To exit type 'exit' or '^D'
> say: "foo"
foo
> say("foo")
foo
> say "foo"
===SORRY!=== Error while compiling:
Two terms in a row
------> say? "foo"
    expecting any of:
        infix
        infix stopper
        statement end
        statement modifier
        statement modifier loop
> 
$ perl6
To exit type 'exit' or '^D'
> say "foo"
foo
> say("foo")
foo
> say: "foo"
foo
> say "foo"
===SORRY!=== Error while compiling:
Two terms in a row
------> say? "foo"
    expecting any of:
        infix
        infix stopper
        statement end
        statement modifier
        statement modifier loop
> 
$ 
Run Code Online (Sandbox Code Playgroud)

似乎在使用" :"或" ()"来提供参数之后,你不能回过头来使用" ",即空格来提供参数.

还是我错过了什么?

谢谢 !!!

lisprog

sml*_*mls 9

say: "foo"

该行并没有调用say子程序.

相反,它声明一个带有名称的语句标签say,然后执行该语句"foo"(什么都不做).

"foo"在你的情况下打印的唯一原因是因为你把它输入到REPL中,它自动打印每行的最后一个语句的值.

如果您在正常程序中使用它,它实际上会抛出警告Useless use of constant string "foo" in sink context.

say "foo" ===SORRY!=== Error while compiling: Two terms in a row ------> say? "foo" expecting any of: infix infix stopper statement end statement modifier statement modifier loop

声明标签后,say此范围中的符号不再引用具有该名称的内置子例程,而是引用自定义标签,使用类似标签时出现语法错误.

但是,错误消息应该理想地解释这一点.我提交了一张Rakudo门票.