lisp可以在lisp中实现这样的糖语法吗?
can lisp implement such a sugar syntax in lisp?
是否可以在 lisp 中实现以下语法?
#1 + 1 &
=>
(+ #1 1)
#1 + #2 &
=>
(+ #1 #2)
"#+(number)" 表示函数的第 n 个参数。
"&" 表示函数结束。
是的。它可以作为 reader 宏来实现,但是你应该知道 (lambda x: x + 1)
和 (lambda x, y: x + y)
在 lisp 中没有任何意义。它看起来像带括号的 python 语法。
现在 reader 宏是将 '(3)
变成 (quote (3))
和 `` (a b ,(+ a b))
变成 (quasiquote (a b (unquote (+ a b))))
的东西
是否可以在 lisp 中实现以下语法?
#1 + 1 &
=>
(+ #1 1)
#1 + #2 &
=>
(+ #1 #2)
"#+(number)" 表示函数的第 n 个参数。 "&" 表示函数结束。
是的。它可以作为 reader 宏来实现,但是你应该知道 (lambda x: x + 1)
和 (lambda x, y: x + y)
在 lisp 中没有任何意义。它看起来像带括号的 python 语法。
现在 reader 宏是将 '(3)
变成 (quote (3))
和 `` (a b ,(+ a b))
变成 (quasiquote (a b (unquote (+ a b))))