From: Lynn Winebarger <owinebar@free-expression.org>
Subject: more syntax silliness
Date: Mon, 19 Aug 2002 10:54:57 -0500 [thread overview]
Message-ID: <0208191054570B.19624@locke.free-expression.org> (raw)
You can still get dynamic redefinition of syntax:
(define tmp
(let ((x 5))
(list
(lambda (y) (set! x y))
(lambda () x)
(lambda (exp)
(syntax-case exp ()
((_ z) (with-syntax ((x2 (datum->syntax-object (syntax _) x)))
(syntax '(z x2)))))))))
(define setx (car tmp))
(define getx (cadr tmp))
(define-syntax foo (caddr tmp))
> (foo bar)
(bar 8)
> (setx 3)
> (let-syntax ((baz (caddr tmp)))
(display (baz bar))
(newline)
(setx 'different)
(display (baz bar))
(newline)
(display (foo bar))
(newline))
(bar 3)
(bar 3)
(bar 3)
> (foo bar)
(bar different)
Now here's the fun part:
> (setx 2)
> (let-syntax ((baz (caddr tmp)))
(display (baz bar))
(newline)
(let-syntax ((foo (let ()
(setx 3)
(caddr tmp))))
(display (baz bar))
(newline)
(display (foo bar))
(newline))
(display (baz bar))
(newline))
(bar 2)
(bar 2)
(bar 3)
(bar 3)
> (setx 2)
> (let-syntax ((baz (caddr tmp)))
(display (baz bar))
(newline)
(let-syntax ((foo (let ()
(setx 3)
(caddr tmp))))
(display (foo bar))
(newline)
(display (baz bar))
(newline))
(display (baz bar))
(newline))
(bar 2)
(bar 3)
(bar 3)
(bar 3)
>
I don't know why the first and the second don't have the same output.
That is, it appears the inner foo's definition doesn't get evaluated until
that foo is actually used. This seems to me a mistake in Chez, but I could be
wrong.
Lynn
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2002-08-19 15:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-19 15:54 Lynn Winebarger [this message]
2002-08-24 4:54 ` more syntax silliness Lynn Winebarger
2002-08-26 21:53 ` Marius Vollmer
2002-08-26 22:30 ` Lynn Winebarger
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=0208191054570B.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).