Changeset 34858 in project


Ignore:
Timestamp:
11/04/17 17:04:42 (4 years ago)
Author:
juergen
Message:

basic-macros 1.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/basic-macros

    r34843 r34858  
    172172documentation procedure
    173173
     174=== define-syntax-rule
     175
     176<macro>(define-syntax-rule (name . args) xpr . xprs)</macro>
     177<macro>(define-syntax-rule (name . args) (keywords . keys) xpr .  xprs)</macro>
     178
     179simplyfied version of syntax-rules if there is only one rule.
     180
     181==== define-ir-macro-transformer
     182
     183<macro>(define-er-macro-transformer (name form inject compare?)</macro>
     184
     185wrapper around ir-macro-transformer.
     186
     187==== define-er-macro-transformer
     188
     189<macro>(define-er-macro-transformer (name form rename compare?)</macro>
     190
     191wrapper around er-macro-transformer.
     192
    174193==== define-er-macro
    175194
     
    200219nothing, and literals in pat and seq must match.
    201220
    202 Must be imported for syntax if used to destucture macro-code in
     221Must be used for-syntax if used to destucture macro-code in
    203222explicit- or implicit-renaming macros.
    204223
     
    215234of the first pattern pat matching seq and passing fenders.
    216235
     236Must be used for-syntax if used to destucture macro-code in
     237explicit- or implicit-renaming macros.
     238
    217239==== once-only
    218240
     
    221243to be used in a macro-body to avoid side-effects.
    222244The arguments x . xs are only evaluated once.
    223 once-only must be imported for-syntax.
     245once-only must be used for-syntax in explicit or implicit renaming
     246macros.
     247
     248==== with-mapped-symbols
     249
     250<macro>(with-mapped-symbols mapper prefix- (prefix-x ...) xpr . xprs)</macro>
     251
     252binds a series of prefixed names, prefix-x ...
     253to the images of the original names, x ..., under mapper
     254and evaluates xpr . xprs in this context.
     255To be used for-synax in ir- or er-macro-transformers, where mapper is
     256either inject or rename.
     257
     258==== with-gensyms
     259
     260<macro>(with-gensyms (x ...) xpr ....)</macro>
     261
     262to be used in a macro body and hence to be imported for-syntax.
     263Generates a list of gensyms x ... which can be used in xpr .....
    224264
    225265=== Requirements
     
    336376
    337377;; swap!
    338 (define-er-macro (swap! form % compare?)
     378(define-er-macro-transformer (swap! form rename compare?)
    339379  (let ((x (cadr form)) (y (caddr form)))
    340     `(,%let ((,%tmp ,x))
    341        (,%set! ,x ,y)
    342        (,%set! ,y ,%tmp))))
     380    (with-mapped-symbols rename % (%tmp %let %set!)
     381      `(,%let ((,%tmp ,x))
     382         (,%set! ,x ,y)
     383         (,%set! ,y ,%tmp)))))
    343384(equal? (let ((x 'x) (y 'y))
    344385          (swap! x y)
     
    402443== Last update
    403444
    404 Oct 30, 2017
     445Nov 04, 2017
    405446
    406447== Author
     
    440481
    441482== Version History
     483; 1.1 : added some additional macros from the procedural-macros egg
    442484; 1.0 : initial import
Note: See TracChangeset for help on using the changeset viewer.