直接引用自己的匿名 lambda [英] Anonymous lambdas directly referring to themselves

查看:36
本文介绍了直接引用自己的匿名 lambda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Scheme 或 Scheme 的任何方言是否有一种自我"运算符,以便匿名 lambda 可以在自己身上重复出现,而无需执行 Y 组合器或在 letrec 中命名等操作.

Does Scheme or do any dialects of scheme have a kind of "self" operator so that anonymous lambdas can recur on themselves without doing something like a Y-combinator or being named in a letrec etc.

类似于:

(lambda (n)
   (cond
     ((= n 0) 1)
     (else (* n (self (- n 1)))))))

推荐答案

没有.当前 lambda"方法的问题在于 Scheme 有许多隐藏的 lambda.例如:

No. The trouble with the "current lambda" approach is that Scheme has many hidden lambdas. For example:

  • 所有let形式(包括let*letrec和named let)
  • do(扩展为命名的 let)
  • 延迟懒惰接收
  • All the let forms (including let*, letrec, and named let)
  • do (which expands to a named let)
  • delay, lazy, receive, etc.

要求程序员知道最里面的 lambda 是什么会破坏封装,因为您必须知道所有隐藏的 lambda 在哪里,并且宏编写者不能再使用 lambda 作为创建新作用域的一种方式.

To require the programmer to know what the innermost lambda is would break encapsulation, in that you'd have to know where all the hidden lambdas are, and macro writers can no longer use lambdas as a way to create a new scope.

全面失败,如果你问我.

All-round lose, if you ask me.

这篇关于直接引用自己的匿名 lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆