guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

macro expander prototype code


From: Lynn Winebarger
Subject: macro expander prototype code
Date: Sun, 1 Sep 2002 06:11:43 -0500

I've written yet another meta-circular partial scheme interpreter.
The main reason for doing this (for me, anyway) is to see
how the macro expansion should work.  It could also
serve as a sort of documentation for eval, as it's structured
_very_ similarly to it (except CPSing).  I don't know how
many people who might want to work on guile have had
the basic PL course where they wrote a Scheme interpreter,
but if someone hasn't, something like this might help.
   I've got the let-syntax/letrec-syntax/define-syntax (both
internal and external) working correctly, but right now the
only transformer available is what I call "unclean-rules"
(the syntax-rules pattern language (actually a little more
powerful) but with absolutely no hygeine).

For example, this works:
(let ()
       (define even?
         (lambda (x)
           (or (= x 0) (odd? (- x 1)))))
       (define-syntax odd?
         (unclean-rules ()
           ((_ y) (not (even? y)))))
       (even? 10)))
 => #t

which is taken directly out of TSPL2, modulo syntax-rules.

   Unfortunately, I doubt this code will run on guile at the
moment.  It uses syntax-case heavily in the form
of a home-brew fixed/variant record system and 
a pattern-case/pattern-let.  I'm using Petite Chez
as I know it has a working syntax-case system. ;-)
    Still, I thought someone else might be interested
in seeing it.  Basically I need to add hygeine and
CPS the interpreter/parser.  Most of the machinery
is there for that too, as I've split lexical environments
from value environments, and classified the bindings
(as macros, values, or top-level which can hold both
simultaneously, as well as a pattern type for syntax)
    Let me know if you're interested.
    
Lynn




reply via email to

[Prev in Thread] Current Thread [Next in Thread]