diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-08-28 06:44:21 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-08-28 06:44:21 -0700 |
commit | 89752b07ce3695fa4302b5db3788fed7b51873d5 (patch) | |
tree | 2e93e716ad830ea49a8f85ac582b77338975500e /txr.1 | |
parent | 1f7a1d489ebfd6b3ef784005b2a52b327979fc58 (diff) | |
download | txr-89752b07ce3695fa4302b5db3788fed7b51873d5.tar.gz txr-89752b07ce3695fa4302b5db3788fed7b51873d5.tar.bz2 txr-89752b07ce3695fa4302b5db3788fed7b51873d5.zip |
expander: do dot-to-apply for meta-expressions.
The dot-to-apply transformation is now applied when
meta-expressions like @foo and @(bar) apparently occur in the
dot position.
This change is made in anticipation of a rewrite of the op
macro, in which the @1, @2, and @rest arguments will be
implemented as macrolets, rather than the ad-hoc, hacky code
walk currently performed in the transform_op function.
* eval.c (dot_meta_list_p): New static function.
(dot_to_apply): Detect the presence of a sys:var or
sys:expr argument in a form. If found, then turn
it and the remaining forms into a single compound
form which replaces them.
* txr.1: Update doc under Dot Position in Function Calls.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -11549,10 +11549,7 @@ for obvious reasons, namely that does not mean that there is a compound form in the dot position, but denotes an alternate spelling for .codn "(a b c foo z)" , -where foo behaves as a variable. (There exists a special exception to this, -namely that the meta-numbers and meta-symbols of the -.code op -operator can be used in the dot position). +where foo behaves as a variable. If the dot position of a compound form is an atom, then the behavior may be understood according to the following transformations: @@ -11562,7 +11559,35 @@ may be understood according to the following transformations: [f a b c ... . x] --> [apply f a b c ... x] .cble -Effectively, the dot notation constitutes a shorthand for +In addition to atoms, meta-expressions and meta-variables can appear in the dot +position, even though their underlying syntax is comprised of a compound +expression. This appears to work according to a transformation pattern +which superficially appears to be the same as that for atoms: + +.cblk + (f a b c ... . @x) --> (apply (fun f) a b c ... @x) +.cble + +However, in this situation, the +.code @x +is actually the form +.code "(sys:var x)" +and the dotted form is actually a proper list. The transformation is +in fact taking place over a proper list, like this: + +.cblk + (f a b c ... sys:var x) --> (apply (fun f) a b c ... (sys:var @x)) +.cble + +That is to say, the \*(TL form expander reacts to the presence of a +.code sys:var +or +.code sys:expr +atom in embedded in the form. That symbol and the items which follow it +are wrapped in an additional level of nesting, converted into a single +compound form element. + +Effectively, in all these cases, the dot notation constitutes a shorthand for .codn apply . Examples: |