←back to thread

Hofstadter on Lisp (1983)

(gist.github.com)
372 points Eric_WVGG | 1 comments | | HN request time: 0.41s | source
1. susam ◴[] No.41862357[source]
> In a testament to the timelessness of Lisp, you can still run all the examples below in emacs if you install these aliases:

> (defalias 'plus #'+)

> (defalias 'quotient #'/)

> (defalias 'times #'*)*

> (defalias 'difference #'-)*

Looks like we also need a defmacro for def that is used much further in the article:

> > (def rac (lambda (lyst) (car (reverse lyst))))

I mean the above example fails in Emacs:

  ELISP> (def rac (lambda (lyst) (car (reverse lyst))))
  *** Eval error ***  Symbol’s function definition is void: def
If we want the above example to work, we need to define def like this:

  ELISP> (defmacro def (name lambda-def) `(defalias ',name ,lambda-def))
  def
Now the previous example, as presented in the article, works fine:

  ELISP> (def rac (lambda (lyst) (car (reverse lyst))))
  rac
  ELISP> (rac '(your brains)) 
  brains