* pmacro expansion snafu?
@ 2009-08-13 17:15 Doug Evans
0 siblings, 0 replies; only message in thread
From: Doug Evans @ 2009-08-13 17:15 UTC (permalink / raw)
To: cgen
I'm adding pmacro builtin .let*. No point in leaving it out.
Anyways, I was adding another testcase for .let and found some
unintuitive behaviour.
guile> (pmacro-trace '(.let ((x y) (y 2)) (.list x y)) (make <location> nil))
Pmacro expanding: (.let ((x y) (y 2)) (.list x y))
Pmacro location: standard input:11:16
Expanding: (.list x y)
env: ((x . y) (y . 2))
location: standard input:11:36
result: (2 2)
Pmacro result: (2 2)
(2 2)
guile> (pmacro-trace '(.let ((x z) (y 2)) (.list x y)) (make <location> nil))
Pmacro expanding: (.let ((x z) (y 2)) (.list x y))
Pmacro location: standard input:14:16
Expanding: (.list x y)
env: ((x . z) (y . 2))
location: standard input:14:36
result: (z 2)
Pmacro result: (z 2)
(z 2)
guile>
The problem is cgen's pmacro expansion will re-evaluate an expanded
pmacro if the expansion also happens to be a pmacro.
So in the first case x -> y, y is also a pmacro, so x -> y -> 2.
The following is even less unintuitive (I think).
guile> (pmacro-trace '(.let ((x y) (y x)) (.list x y)) (make <location> nil))
Pmacro expanding: (.let ((x y) (y x)) (.list x y))
Pmacro location: standard input:15:16
Expanding: (.list x y)
env: ((x . y) (y . x))
location: standard input:15:36
result: (x y)
Pmacro result: (x y)
(x y)
guile>
I expected to get (y x), but x -> y (which is also a pmacro, so ...) -> x
and similarly y -> x -> y.
I'm not sure I prefer this behaviour.
Comments?
I'm happy with removing cgen's quirky pmacro expansion so that
(.let ((x y) (y x)) (.list x y)) -> (y x)
if that's the preferred thing to do.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-08-13 17:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-13 17:15 pmacro expansion snafu? Doug Evans
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).