This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Reintroducing old `defined?'


Russ McManus <russell.mcmanus@gs.com> writes:

> > Actually, in the large majority of cases it's *much* simpler to write
> > syntax-case macros than defmacros, and what is great about them is
> > that they work.  They don't cause strange unexpected errors due to
> > identifier collisions.
> 
> Yes, that has always been the promise.

It's actually more than a promise.  Guile already has syntax-case
macros, although they aren't yet implemented on low-level.

Say (use-syntax (ice-9 syncase)) in a recent snapshot.  (I think
there's some trouble with the use-syntax form in 1.3.)

(The above actually introduces a transformer which parses all code.
This is necessary to get 100% pure behaviour, but in most cases
(use-module (ice-9 syncase)) works as well, and doesn't require code
transformation.)

> > Many people got scared of hygienic macros after seeing the low-level
> > macro facility in R4RS.  In addition to providing the easy-to-use
> > high-level facility from R5RS (`syntax-rules'), syntax-case macros
> > also support *easy-to-use* low-level power!
> 
> But how do I learn them?  I have a lovely learning device for
> defmacro's, Graham's 'On Lisp', but I couldn't find anything about how
> to pick up syntax-case.

Kent Dybvig has written a wonderful book "The Scheme Programming
Language" the 2nd ed. which has recently been published.  This book
also exists on-line.  Have a look at

  http://www.scheme.com/tspl2d/syntax.html

> > Also, syntax-case macros integrate naturally with a
> > module-system---they don't insert undefined bindings into the
> > caller's code.
> 
> I lost you here.

Module A exports

  (defmacro foo (x)
    `(bar ,x))

Module B imports foo, but not bar.

  (foo 'gurka) --> Error: bar undefined

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]