From: Lynn Winebarger <owinebar@free-expression.org>
Subject: macro expander prototype code
Date: Sun, 1 Sep 2002 06:11:43 -0500 [thread overview]
Message-ID: <0209010611431T.19624@locke.free-expression.org> (raw)
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
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
reply other threads:[~2002-09-01 11:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0209010611431T.19624@locke.free-expression.org \
--to=owinebar@free-expression.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).