diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-07-22 07:42:13 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-07-22 07:42:13 -0700 |
commit | fb8a30d4540d04b02f98e7895cdb02d5c7f6c2e6 (patch) | |
tree | 31ec91d7811979add1817bdfe829bcc139d609b9 /txr.1 | |
parent | 9d2a3e3ba7e75d200ee1d9ece7c2accd7451a960 (diff) | |
download | txr-fb8a30d4540d04b02f98e7895cdb02d5c7f6c2e6.tar.gz txr-fb8a30d4540d04b02f98e7895cdb02d5c7f6c2e6.tar.bz2 txr-fb8a30d4540d04b02f98e7895cdb02d5c7f6c2e6.zip |
* lisplib.c (place_set_entries): Add *place-macro* and
define-place-macro to list of names.
* share/txr/stdlib/place.tl (*place-macro*): New global hash.
(sys:tigger-load, sys:pl-expand): New functions.
(call-update-expander, call-clobber-expander, call-delete-expander):
Recognize and expand place macros.
(define-place-macro): New macro.
(first, rest): Places redefined using define-place-macro, replacing
the old hack of copying the expanders from one table entry to another.
* txr.1: Documented place macros.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 47 |
1 files changed, 44 insertions, 3 deletions
@@ -9924,10 +9924,14 @@ are both open-ended. Code can be written quite easily in \*(TL to introduce new kinds of places, as well as new place-mutating operators. New places can be introduced with the help of the .code defplace -macro. New place update macros (place operators) are written using the +macro, or possibly the +.code define-place-macro +macro in simple cases when a new syntactic place can be expressed as a +transformation to the syntax of an existing place. +New place update macros (place operators) are written using the ordinary macro definer -.code defmacro -but with the help of special utility macros called +.codn defmacro , +with the help of special utility macros called .codn with-update-expander , .codn with-clobber-expander , and @@ -30251,6 +30255,43 @@ cells: ,body))) .cble +.coNP Macro @ define-place-macro +.synb +.mets (define-place-macro < name < macro-style-params +.mets \ \ << body-form *) +.syne +.desc +In some situations, an equivalence exists between two forms, only one +of which is recognized as a place. The +.code define-place-macro +macro can be used to establish a form as a place in terms of a translation to +an equivalent form which is already a place. + +The +.code define-place-macro +has the same syntax as +.codn defmacro . +It specifies a macro transformation for a compound form which has the +.meta name +symbol in its leftmost position. +This macro expansion is applied when such a form is used as a place. +It is applied after all other expansions, and no other macro-expansions +are applied afterward. + +.TP* "Example:" + +Implementation of +.code first +in terms of +.codn car : + +.cblk + (define-place-macro first (obj) + ^(car ,obj)) +.cble + +.coNP Operator @ defmacro + .coNP Macro @ rlet .synb .mets (rlet >> ({( sym << init-form )}*) << body-form *) |