Why don't people like lisp?

Jon S. Anthony j-anthony at rcn.com
Thu Oct 23 19:35:05 EDT 2003


Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes:

> On Thu, 23 Oct 2003 12:11:30 -0400, Joe Marshall wrote:
> 
> > So if we extended Lisp, for example, I could write:
> 
> > (defun pythagorean-triples (n)
> >   (all-values
> >     (let ((opposite (an-integer-between 1 n))
> >           (adjacent (an-integer-between 1 n))
> >           (hypotenuse (an-integer-between 1 n)))
> >       (if (= (+ (* opposite opposite)
> >                 (* adjacent adjacent))
> >              (* hypotenuse hypotenuse))
> >           (list opposite adjacent hypotenuse)
> >           (fail)))))
> 
> How to write such macros in Lisp? Looks like they would require
> non-local rewriting of program structure, I don't see how it's
> possible at all.

Huh?  It's not only possible it's been done.  Many times.  In fact it
is just this sort of thing that people have been trying to explain
that makes them so enormously useful in producing _naturally_
expressive code.

The above example (with some differing details I think) is given by
Paul Graham in 2-3 pages of code in On Lisp in the Nondeterminism
chapter.  He then uses this to implement an embedded Prolog in another
couple pages (the continuation style implementation for Prolog is not
the best one for Common Lisp - though probably fine for Scheme with
call/cc.  Norvig gives a good one in PAIP, with it's own embedded
compiler - all with macros).

/Jon





More information about the Python-list mailing list