Changeset 40133 in project


Ignore:
Timestamp:
05/24/21 22:32:18 (3 weeks ago)
Author:
Idiomdrottning
Message:

New semantics for define-ir-syntax* and define-ir-syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/brev-separate

    r40124 r40133  
    4141Here's an example:
    4242
    43  (define-ir-syntax* aif
     43 (define-ir-syntax*
     44   (aif test yes no)
     45   `(let ((,(inject 'it) ,test))
     46      (if ,(inject 'it) ,yes ,no)))
     47 
     48 (aif (... expensive test ...)
     49      (car it)
     50      (print "oh! no!"))
     51
     52When you have multiple call-signatures, wrap pattern / body set with parens.
     53
     54 (define-ir-syntax*
     55   ((aif #f yes no) no)
    4456   ((aif test yes no)
    4557    `(let ((,(inject 'it) ,test))
    4658       (if ,(inject 'it) ,yes ,no))))
    47  
    48  (aif (... expensive test ...)
    49       (car it)
    50       (print "oh! no!"))
    5159
    5260
     
    5866 (define-ir-syntax name body)
    5967
    60 where the body has access to {{exp}}, {{inject}}, {{compare}}, {{strip-syntax}} and {{syntax}}.
    61 
    62 {{exp}} is the macro call as a whole, as in the following example:
     68where the body has access to {{body}}, {{inject}}, {{compare}},
     69{{strip-syntax}} and {{syntax}}, as in the following example:
    6370
    6471 (define-ir-syntax comp-prod
    65    (apply * (cdr exp)))
     72   (apply * body))
    6673 
    6774 (comp-prod 2 3 4)
Note: See TracChangeset for help on using the changeset viewer.