开发者

The most minimal LISP? [duplicate]

This question already has answers here: Closed 12 years ago. 开发者_如何学C

Possible Duplicate:

How many primitives does it take to build a LISP machine? Ten, seven or five?

I am curious. What is the most minimal LISP, upon which all further features could be built? Ignore efficiency -- the question comes simply from a place of elegance.

If you awoke on an alien planet and were instructed to build the most minimal LISP that you could later build upon to implement any feature you liked, what would you include?

Edit: Clarification. My intent here is not to start a debate, rather I am considering implementing a minimal LISP and I want to understand how minimal I can go while still allowing the language I implement to be Turing complete, etc. If this turns out to be controversial I am sure I will learn what I wanted to learn from observing the controversy. :). Thanks!


Courtesy of Paul Graham, here's a Common Lisp implementation of John McCarthy's original LISP:

It assumes quote, atom, eq, cons, car, cdr, and cond, and defines null, and, not, append, list, pair, assoc, eval, evcon and evlis.


Peter Norvig implemented a LISP interpreter in 90 lines of Python, and his subsequent article discusses in detail what you're asking. Well worth the read, IMHO.

http://norvig.com/lispy.html

I've got a feeling that his "sequencing" special form could be dropped if only function calls could take an arbitrary number of parameters.

(defun last (lst)
  (if (cdr lst) 
      (last (cdr lst))
      (car lst)))

(defun begin (:rest y) (last y))

But this would complicate function application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜