From: Ralph Richard Cook
Subject: Looking for comments on this comment on Scheme macros
Date: 
Message-ID: <4148ff78.3710545@newsgroups.bellsouth.net>
From "Using a hierarchy of Domain Specific Languages in complex
software systems design" (http://www.arxiv.org/abs/cs.PL/0409016),
Vitaly Lugovsky says "and even the current Scheme standard R5RS
contains only hygienic macros that can hardly be recognized as 'true'
macros as they hide an access to the host language."

How do Scheme macros hide access, and are Common Lisp macros "better"?

From: Pascal Costanza
Subject: Re: Looking for comments on this comment on Scheme macros
Date: 
Message-ID: <cibgjf$463$1@newsreader2.netcologne.de>
Ralph Richard Cook wrote:
> From "Using a hierarchy of Domain Specific Languages in complex 
> software systems design" (http://www.arxiv.org/abs/cs.PL/0409016), 
> Vitaly Lugovsky says "and even the current Scheme standard R5RS 
> contains only hygienic macros that can hardly be recognized as 'true'
> macros as they hide an access to the host language."
> 
> How do Scheme macros hide access, and are Common Lisp macros
> "better"?

There is an introduction to macro programming in Scheme by Joe Marshall
at http://home.comcast.net/~prunesquallor/macro.txt - he says the following:

"SYNTAX-RULES is based on token-replacement.  SYNTAX-RULES defines a
series of patterns and templates.  The form is matched against the
pattern and the various pieces are transcribed into the template.
This seems simple enough, but there is one important thing to always
keep in mind.

*** THE SYNTAX-RULES SUBLANGUAGE IS NOT SCHEME!"

(SYNTAX-RULES is the widely used name for the R5RS macro system because 
that's the name of its major construct.)

Since SYNTAX-RULES is not Scheme, you cannot make use of the Scheme 
language inside your macro definitions. Joe's article describes ways how 
to reimplement some of the standard functionality provided with Scheme, 
but you essentially have to reimplement them.

Common Lisp macros (DEFMACRO) are expressed in their host language, so 
you can just reuse everything in it, including third-part libraries and 
everything you have written in the host language yourself.

You can find excellent introductions to macro programming in Common Lisp 
in Paul Graham's "On Lisp" and Peter Norvig's "Paradigms of Artificial 
Intelligence Programming". The first book is available for free at 
Paul's website.


Pascal

-- 
Tyler: "How's that working out for you?"
Jack: "Great."
Tyler: "Keep it up, then."
From: Jens Axel Søgaard
Subject: Re: Looking for comments on this comment on Scheme macros
Date: 
Message-ID: <41499803$0$210$edfadb0f@dread11.news.tele.dk>
Ralph Richard Cook wrote:

> From "Using a hierarchy of Domain Specific Languages in complex
> software systems design" (http://www.arxiv.org/abs/cs.PL/0409016),
> Vitaly Lugovsky says "and even the current Scheme standard R5RS
> contains only hygienic macros that can hardly be recognized as 'true'
> macros as they hide an access to the host language."
> 
> How do Scheme macros hide access, and are Common Lisp macros "better"?

The syntax-rules macros defined in the current Scheme standard
can be implemented by a several "low-level" macro systems. At the
time of standardization there were no clear conclusion to which
"low-level" macro system that were preferable. As the years passes
by more and more Scheme implementations provide support for Dybvig
et al's syntax-case macros. They provide easy access to the best
parts of syntax-rules macros, but like defmacro in Common Lisp also
allow evaluation of arbitrary expressions at compile time.

See Dybvig's paper "Syntactic abstraction in Scheme"
<http://www.cs.indiana.edu/~dyb/pubs/LaSC-5-4-pp295-326.pdf>.

To get a grasp of the ideas and use of syntax-case read
"Writing hygienic macros in Scheme with syntax-case" first.
(<http://www.cs.indiana.edu/~dyb/pubs/tr356.pdf>)

Later Flatt attacked the problems that macros make a
module system face in "Composable and Compilable Macros: You
Want it When?". <http://www.cs.utah.edu/plt/publications/macromod.pdf>.

In short: The R5RS is old and a lot has happened since. The
new Scheme Strategy Commitee will probably raise bar
(<http://www.schemers.org/Documents/Standards/Charter/jan-2004.txt>).


For a comprehensive list of papers on macros see:

     <http://library.readscheme.org/page3.html>

Dybvig's page on the portable syntax-case macro system:

     <http://www.cs.indiana.edu/chezscheme/syntax-case/>

-- 
Jens Axel Søgaard