为什么Emacs lisp中没有尾递归优化,而不是像其他方案一样? [英] Why is there no tail recursion optimization in Emacs lisp, not but like other scheme?

查看:232
本文介绍了为什么Emacs lisp中没有尾递归优化,而不是像其他方案一样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Emacs lisp是LISP的一种方言,特别是Scheme。大多数方案口译员确实对尾递归进行了优化,但是emacs lisp不这样做。我在'info elisp'搜索了一段时间的原因,但是我找不到它。

Emacs lisp is a dialect of LISP and especially Scheme. Most of scheme interpreters do have a optimization of Tail Recursion, but emacs lisp doens't. I searched the reason in `info elisp' for a while, but I fail to find it.

是的,elisp中还有其他的迭代语法,如`while',但是我仍然找不到一个很好的理由,为什么他们没有像其他方案解释器那样执行尾递归。

P.S. Yes, there is other iteration syntax in elisp like `while', but I still cannot find a good reason why they didn't implement tail recursion like other scheme interpreters.

推荐答案

Emacs Lisp是在20世纪80年代创建的。 Emacs作者(Richard Stallman)当时最熟悉的Lisp方言是MIT Maclisp,Emacs Lisp非常相似。它使用动态变量范围,没有词法闭包或尾递归优化,Emacs Lisp是一样的。

Emacs Lisp was created in the 1980's. The Lisp dialect that the Emacs author (Richard Stallman) was most familiar with at the time was MIT Maclisp, and Emacs Lisp is very similar to it. It used dynamic variable scoping and did not have lexical closures or tail recursion optimization, and Emacs Lisp is the same.

Emacs Lisp与Scheme非常不同。最大的区别是Scheme是词法的范围,但最近才被添加到Emacs Lisp中,并且必须在每个文件的基础上启用(通过放入 ;;; * - 词法绑定:t - * - 在第一行),因为默认情况下会这样做会导致许多不兼容。

Emacs Lisp is very different from Scheme. The biggest difference is that Scheme is lexically scoped, but this was only recently added to Emacs Lisp, and it has to be enabled on a per-file basis (by putting ;;; -*- lexical-binding: t -*- on the first line) because doing it by default would cause many incompatibilities.

已经有一些工作来替换Emacs Lisp与Guile,计划方言。但是还不清楚是否有成果。

There has been some work to replace Emacs Lisp with Guile, a Scheme dialect. But it's not clear whether it will ever reach fruition.

这篇关于为什么Emacs lisp中没有尾递归优化,而不是像其他方案一样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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