Changeset 32941 in project


Ignore:
Timestamp:
11/26/15 10:42:22 (5 years ago)
Author:
juergen
Message:

explicit-ranaming-macros and juergen-lorenz updated

Location:
wiki
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wiki/explicit-renaming-macros

    r32914 r32941  
    230230bind, but what about renaming/injecting and additional keywords?
    231231
    232 Well, the bindings module will help with solving these problems
    233 as well.  For example, we've provided a version of define-macro, which
    234 cares for all three arguments of the macro-transformer. Without
    235 injecting and additional keywords its syntax is identical to
    236 that of our old friend from CHICKEN-3
     232Well, the procedural-macros module will help with solving these
     233problems.  For example, we've provided a procedural variant of
     234syntax-rules, named macro-rules, which cares for all three arguments of
     235the macro-transformer, and -- based on it -- a hygienic version of
     236define-macro.
    237237
    238238<enscript highlight="scheme">
     
    243243</enscript>
    244244
    245 But this is now hygienic!
    246 
    247 In case you prefer a macro more similar to syntax-rules, use
    248 macro-rules, which uses traditional quasiquoted templates and allows for
    249 injected symbols before the keyword-list.
     245This is now hygienic!
     246
     247The following is an example for using maro-rules, a verbose if, whith
     248additional keywords.
    250249
    251250<enscript highlight="scheme">
    252251(define-syntax vif
    253252  (macro-rules (then else)
    254     ((_ test (then xpr . xprs))
     253    ((_ test (then . xprs) (else . yprs))
    255254     `(if ,test
    256         (begin ,xpr ,@xprs)))
    257     ((_ test (else xpr . xprs))
    258      `(if ,(not test)
    259         (begin ,xpr ,@xprs)))
    260     ((_ test (then xpr . xprs) (else ypr . yprs))
    261      `(if ,test
    262         (begin ,xpr ,@xprs)
    263         (begin ,ypr ,@yprs)))))
    264 </enscript>
     255                                (begin ,@xprs)
     256                                (begin ,@yprs)))))
     257</enscript>
     258
     259But note, the real power of procedural macros result from the fact, that
     260you have complete control over the evaluation time. For example, you can
     261use local procedures evaluated at compile time!
    265262
    266263For details see
    267264
    268 [[/eggref/4/bindings|bindings]]
    269 
    270 Low level macros are really great ...
     265[[/eggref/4/procedural-macros|procedural-macros]]
     266
     267Procedural macros are really great ...
    271268
    272269== Author
     
    280277== Updated
    281278
    282 Nov 17, 2015
     279Nov 26, 2015
  • wiki/users/juergen-lorenz

    r32518 r32941  
    99=== Eggs
    1010
     11==== [[/eggref/4/procedural-macros|procedural-macros]]
     12
     13Some macros which help to write procedural macros. For example, a
     14hygienic version of define-macro and a procedural variant of
     15syntax-rules, called macro-rules, which is as easy to use as the latter
     16but much more powerfull.
     17
    1118==== [[/eggref/4/bindings|bindings]]
    1219
     
    1724arbitrary sequence types, the client may add later. The most important
    1825one is bind, a variant of Common Lisp's destructuring-bind.
    19 
    20 As an application, macros are provided, which facilitate the writing of
    21 hygienic procedural macros, in particular a hygienic version of
    22 define-macro.
    2326
    2427==== [[/eggref/4/datatypes|datatypes]]
Note: See TracChangeset for help on using the changeset viewer.