0

这是鸡计划中的错误吗?

#;1> (define (foo x . y) x)
#;2> (foo 1 2 3)
1
#;3> (module bar (import scheme chicken) (define (foo x . y) x))

Error: invalid syntax in macro form: (foo x . y)

        Call history:

        <syntax>                (module bar (import scheme chicken) (define (foo x . y) x))
        <syntax>                (##core#module bar (import scheme chicken) (define (foo x . y) x))
        <syntax>                (define (foo x . y) x)
        <syntax>                (foo x . y)     <--
4

2 回答 2

0

The dot (.) syntax for variadic functions is not available across modules; it's inside the scheme module. When you create a custom module, you have to explicitly import the scheme module to reenable variadic functions.

#1;> (module bar (foo) (import scheme chicken) (define (foo x . y) x))
#2;> (import bar)
#3;> (foo 1 2 3)
1
于 2011-10-19T18:27:46.603 回答
0

您的模块语法缺少要从模块导出的符号列表。尝试这个:

#1;> (module bar (foo) (import scheme chicken) (define (foo x . y) x))
#2;> (import bar)
#3;> (foo 1 2 3)
1

注意声明模块名称后的 (foo) 。

我要补充一点,邮件列表和 irc 频道(freenode 上的#chicken)非常活跃。如果您对鸡肉有任何疑问,他们是回答问题的最佳场所。

于 2011-10-19T15:48:05.503 回答