diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-07 19:16:32 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-09-07 19:16:32 -0700 |
commit | 957f80f26807582927fa580c705e9aa59327771d (patch) | |
tree | 7af73f9d874b89504f3e702a4ccafd66ab53c902 | |
parent | 703e6ec56c8cd1eb33b6572fde69c454587c0beb (diff) | |
download | txr-957f80f26807582927fa580c705e9aa59327771d.tar.gz txr-957f80f26807582927fa580c705e9aa59327771d.tar.bz2 txr-957f80f26807582927fa580c705e9aa59327771d.zip |
Bugfix: issue with expansion of place macros.
The expansion of a place macro form should not be
subject to a complete macro-expansion (as a
regular macro form). Only one round of expansion
should be performed, and the results should be
re-tried as a place macro. Otherwise an opportunity
to expland a place macro will be missed.
* share/txr/stdlib/place.tl (sys:pl-expand):
Use macroexpand-1 rather than macroexpand.
* txr.1: Documentation updated to make the new behavior
clear. It's unlikely that anything in the world depends
on this, so no backward compatibility switch is being
provded to the old behavior. In situations where this
makes a difference, the old behavior is likely too wrong
to be useful.
-rw-r--r-- | share/txr/stdlib/place.tl | 2 | ||||
-rw-r--r-- | txr.1 | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/share/txr/stdlib/place.tl b/share/txr/stdlib/place.tl index 6437ac45..dbae39be 100644 --- a/share/txr/stdlib/place.tl +++ b/share/txr/stdlib/place.tl @@ -139,7 +139,7 @@ (sys:setq place (sys:set-macro-ancestor [pm-expander unex-place] unex-place)))) - (sys:setq place (macroexpand place env)) + (sys:setq place (macroexpand-1 place env)) (when (or (eq place unex-place) (null place) (and (atom place) (not (symbolp place))) @@ -27430,15 +27430,21 @@ symbol in its leftmost position. Forms which are used as syntactic places are subject to a modified macro-expansion algorithm. If a place macro applies to a place, then it is expanded, otherwise it is taken as-is. Then the place is expanded as a ordinary -macro (possibly a symbol macro). Then the process is repeated from the -beginning, as necessary. Thus, the output of the ordinary macro expansion may -potentially be, again, a place macro. Place macros can expand to other place +macro (possibly a symbol macro), if possible, but only through at most +one round of macro-expansion, as if by +.codn macroexpand-1 . +If the macro-expansion succeeds, its its output might be, again, a place +macro form, and so the process is tried again. Place macros can expand to other place macros or ordinary macros and vice versa. Place macro expansion doesn't use an environment; place macros are in a single global namespace, special to place macros. There are no lexically scoped place macros. Such an effect can be achieved by having a place macro expand to an a form which is the target of a global or local macro, as necessary. +That said, it needs to be made clear that the ordinary macro-expansion +that may be interleaved within place-macro-expansion does take place +in the surrounding macro environment. A place macro can expand to a form +which matches a lexical macro visible at that point. The .code define-place-macro |