Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Q: where to find code for COND, LET, DO, etc.

9 views
Skip to first unread message

Luca Lizzeri

unread,
Jul 22, 1995, 3:00:00 AM7/22/95
to
I am very curious as to how the various "system" macros are
implemented.
Anyone out there has any idea where to look ?
Luca Lizzeri Telefono: +39.2.8053884
l...@niche.telnetwork.it Fax: +39.2.4982660
Indirizzo: Via Caminadella, 6
20123 Milano, Italia


David B. Lamkins

unread,
Jul 22, 1995, 3:00:00 AM7/22/95
to
In article <3uquq9$n...@stargate.telnetwork.it>, l...@niche.telnetwork.it
(Luca Lizzeri) wrote:

> I am very curious as to how the various "system" macros are
> implemented.

Take a look at the book "Lisp" by Winston & Horn. They develop a small
Lisp interpreter in Lisp. Ditto for "Structure and Interpretation of
Computer Programs" by Abelson & Sussman.

Online, you can take a look at
ftp://ftp.eecs.harvard.edu/users/rtm/lisp.lisp for some definitions.

Dave
--
CPU Cycles: Use them now or lose them forever...
http://www.teleport.com/~dlamkins

William Paul Vrotney

unread,
Jul 23, 1995, 3:00:00 AM7/23/95
to

In article <3uquq9$n...@stargate.telnetwork.it> l...@niche.telnetwork.it (Luca Lizzeri) writes:

>
> I am very curious as to how the various "system" macros are
> implemented.

> Anyone out there has any idea where to look ?
> Luca Lizzeri Telefono: +39.2.8053884
> l...@niche.telnetwork.it Fax: +39.2.4982660
> Indirizzo: Via Caminadella, 6
> 20123 Milano, Italia
>

In Common Lisp to see the implementation of a macro just use MACROEXPAND
on the expression you are interested in. For example a COND expression

(macroexpand '(cond (a b) (c d)))

would return something like

(IF A (PROGN B) (COND (C D)))

This is guaranteed to work even if the macro is implemented as a special
form. For example some will implement COND as a special form, which you
could determine with

(special-form-p 'cond)

Note that an implementation is free to expand what ever it likes for a
macro, for example on another implementation the above MACROEXPAND might
expand to

(IF A B (IF C D NIL))

--

William P. Vrotney - vro...@netcom.com

Message has been deleted

Marty Hall

unread,
Jul 27, 1995, 3:00:00 AM7/27/95
to
In article <DCC9r...@rheged.dircon.co.uk> si...@rheged.dircon.co.uk (Simon Brooke) writes:
>In article <vrotneyD...@netcom.com>,

>William Paul Vrotney <vro...@netcom.com> wrote:
>>
>>In Common Lisp to see the implementation of a macro just use MACROEXPAND
>>on the expression you are interested in. For example a COND expression
>>
>> (macroexpand '(cond (a b) (c d)))
>>
>>would return something like
>>
>> (IF A (PROGN B) (COND (C D)))
>
>I am interested and surprised. I always think of IF as a macro which
>expands to COND -- COND being after all one of the dozen or so most
>fundamental bits of LisP. It would be mildly interesting to know which
>implementations of CL treat COND as primitive, and which IF.

On Suns, all three of Franz Allegro CL, Harlequin LispWorks, and Lucid
CL expand (cond (a b) (c d)) into some sort of IF.

Franz: (IF A (PROGN B) (COND (C D)))
Harlequin: (IF A (PROGN B) (IF C (PROGN D) NIL))
Lucid: (IF A B (IF C D NIL))
- Marty
(proclaim '(inline skates))

Erik Naggum

unread,
Jul 27, 1995, 3:00:00 AM7/27/95
to
[Simon Brooke]

| I am interested and surprised. I always think of IF as a macro which
| expands to COND -- COND being after all one of the dozen or so most
| fundamental bits of LisP. It would be mildly interesting to know which
| implementations of CL treat COND as primitive, and which IF.

Common Lisp must differ from that mythical "LisP", because `if' is a
special form/operator in Common Lisp, and `cond' is a macro. see CLtL2,
p. 156ff.

#<Erik 3015864904>
--
NETSCAPISM /net-'sca-,pi-z*m/ n (1995): habitual diversion of the mind to
purely imaginative activity or entertainment as an escape from the
realization that the Internet was built by and for someone else.

William Paul Vrotney

unread,
Jul 28, 1995, 3:00:00 AM7/28/95
to
In article <DCC9r...@rheged.dircon.co.uk> si...@rheged.dircon.co.uk (Simon Brooke) writes:

>
> In article <vrotneyD...@netcom.com>,
> William Paul Vrotney <vro...@netcom.com> wrote:
> >
> >In Common Lisp to see the implementation of a macro just use MACROEXPAND
> >on the expression you are interested in. For example a COND expression
> >
> > (macroexpand '(cond (a b) (c d)))
> >
> >would return something like
> >
> > (IF A (PROGN B) (COND (C D)))
>

> I am interested and surprised. I always think of IF as a macro which
> expands to COND -- COND being after all one of the dozen or so most
> fundamental bits of LisP. It would be mildly interesting to know which
> implementations of CL treat COND as primitive, and which IF.
>

COND used to be a fundamental form in Lisp. But now in Common Lisp there is
WHEN and UNLESS along with COND all making up a similar family of
conditionals all of which can be implemented with the more primitive form
IF.

Again, an implementation is free to implement COND (or any macro form) as a
special form (primitive) as long as it also provides a macro expansion for
that form. All of the special forms (there is only a handfull of them
including IF) however must be implemented as special forms. It is
instructive to look at the small set of special forms of Common Lisp and see
if you can come up with a simpler set.

Luca Lizzeri

unread,
Sep 4, 1995, 3:00:00 AM9/4/95
to
l...@niche.telnetwork.it (Luca Lizzeri) wrote:

>I am very curious as to how the various "system" macros are
>implemented.
>Anyone out there has any idea where to look ?

Turns out I had some idea about where to look: my hard disk.

I have GCL for Linux and CLisp for DOS and Linux. They both
come with lisp sources for system functions and macros.

For reference:
GCL: ftp://ftp.cli.com/pub/gcl
ftp://ftp.ma.utexas.edu/pub/gcl
CLisp: ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/lisp/clisp.

Thanks to all who responded anyway.

Jack Harper

unread,
Sep 5, 1995, 3:00:00 AM9/5/95
to
In article <42fq9q$6...@stargate.telnetwork.it>, l...@niche.telnetwork.it
(Luca Lizzeri) wrote:

You might also read, if you have not already, as a point of historical
interest, if nothing else, John McCarthy's book "Lisp 1.5 Programmer's
Manual" (circa 1965) for the original ideas etc. from God himself. Page 70
is a good spot to start.

Regards.

---------------------------------------------------------------------
Jack Harper Bank Systems 2000, Inc.
e-mail: jha...@bs2000.com 350 Indiana Street, Suite 350
voice: 303-277-1892 fax: 303-277-1785 Golden, Colorado 80401 USA

"21st Century Banking Applications"
Private Label Bank Laser Card Systems
Visit our Web Page: http://www.bs2000.com/talos
---------------------------------------------------------------------

Scott Wheeler

unread,
Sep 6, 1995, 3:00:00 AM9/6/95
to
In Article <jharper-0509...@p2.denver1.dialup.csn.net> Jack
Harper writes:

>You might also read, if you have not already, as a point of historical
>interest, if nothing else, John McCarthy's book "Lisp 1.5 Programmer's
>Manual" (circa 1965) for the original ideas etc. from God himself.

I don't suppose anyone's ever re-printed? I'd like to get a copy.

Scott

Richard M. Alderson III

unread,
Sep 8, 1995, 3:00:00 AM9/8/95
to
In article <jzb...@bmtech.demon.co.uk> Scott Wheeler
<sco...@bmtech.demon.co.uk> writes:

I believe it's still in print, from MIT Press. My 10-year-old copy has the
ISBN 0-262-13011-4. They are, at the very least, a good place to start.
--
Rich Alderson You know the sort of thing that you can find in any dictionary
of a strange language, and which so excites the amateur philo-
logists, itching to derive one tongue from another that they
know better: a word that is nearly the same in form and meaning
as the corresponding word in English, or Latin, or Hebrew, or
what not.
--J. R. R. Tolkien,
alde...@netcom.com _The Notion Club Papers_

0 new messages