Subject: Re: Yet another Smalltalk or Lisp discussion (Windows Centric)
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 08 Sep 2006 06:06:46 -0500
Newsgroups: comp.lang.smalltalk,comp.lang.lisp
Message-ID: <raydnRqNld1b05zYnZ2dnUVZ_vOdnZ2d@speakeasy.net>
Chris Uppal <chris.uppal@metagnostic.REMOVE-THIS.org> wrote:
+---------------
| Put it like this. If Lisp had (mabe it has, for all I know)
| a simple and clear syntax for indicating deferred evaluation...
+---------------

You mean like these?

    > (defmacro thunk (&body body) `(lambda () ,@body))

    THUNK
    > (defmacro fn (args &body body) `(lambda ,args ,@body))

    FN
    > (mapcar (fn (x y) (+ x y)) '(1 2 3 4) '(0 5 10 15))

    (1 7 13 19)
    > 

Or if you *insist* on getting all "syntaxy":

    > (mapcar #$(+ $1 $2) '(1 2 3 4) '(0 5 10 15))

    (1 7 13 19)
    > 

[The definition of the "#$" readmacro is left to the reader, but
it's real (and really, *really* ugly!), and I do use it in the REPL
once in a while, through *NEVER* in finished code! (Guess why?)]

+---------------
| ...then are there any cases where macros are used that could not
| be replaced by an combination of ordinary functional evaluation
| (possibly introspective), and the application of that syntax?
+---------------

You're missing the distinction between "could be replaced" and
"would be *desirable* to be replaced". Many, many uses of macros
are simply because they make the code *look* better and/or be more
*readable* [and thus more maintainable in the long term], and in
the Common Lisp community this is valued more than any sort of
"functional purity".


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607