Changeset 33077 in project
 Timestamp:
 01/11/16 19:17:59 (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/proceduralmacros
r32952 r33077 36 36 usual, i.e. the pattern on the left is repeated zero or more times, two 37 37 dots, zero or one time, 4 dots one ore several times. 38 38 39 39 40 This form can be used instead of syntaxrules in definesyntax, … … 144 145 like syntaxrules, but the templates are usually quasiquoteexpressions. 145 146 Moreover, the symbols sym ... are injected, if there are any. 147 Here and in the sequel, fender is an expresseion of the form 148 (var ok? ...) 149 checking a pattern variable, var, against a sequence of predicates. 146 150 147 151 Note, that nonsymbol literals are accepted in each pat and … … 269 273 ;; procedural version of letrec 270 274 (definemacro (myletrec varvalpairs . body) 271 (where ( (listof? pair?) varvalpairs))275 (where (varvalpairs (listof? pair?))) 272 276 (let ((vars (map car varvalpairs)) 273 277 (vals (map cadr varvalpairs)) … … 300 304 301 305 (macrolet ( 302 ((fir lst) (where (l ist? lst)) `(car ,lst))303 ((res lst) (where (l ist? lst)) `(cdr ,lst))306 ((fir lst) (where (lst list?)) `(car ,lst)) 307 ((res lst) (where (lst list?)) `(cdr ,lst)) 304 308 ) 305 309 (fir (res '(1 2 3)))) … … 311 315 ((_ "foo" x) x) 312 316 ((_ #f x) x) 313 ((_ a b) (where ( string? a)) `(list ,a ,b))314 ((_ a b) (where ( odd? a)) `(list ,a ,b))317 ((_ a b) (where (a string?)) `(list ,a ,b)) 318 ((_ a b) (where (a odd?)) `(list ,a ,b)) 315 319 ((_ a b) a))) 316 320 (foo "foo" 1) … … 327 331 (definesyntax add 328 332 (macrorules () 329 ((_ x y) (where ( string? x) (string? y))333 ((_ x y) (where (x string?) (y string?)) 330 334 `(stringappend ,x ,y)) 331 (( _ x y) (where ( integer? x) (integer? y))335 (( _ x y) (where (x integer?) (y integer?)) 332 336 `(+ ,x ,y)))) 333 337 (add 1 2) … … 339 343 == Last update 340 344 341 Dec 01, 2015 345 Jan 11, 2016 342 346 343 347 == Author … … 347 351 == License 348 352 349 Copyright (c) 2015 , Juergen Lorenz353 Copyright (c) 20152016, Juergen Lorenz 350 354 All rights reserved. 351 355 … … 377 381 378 382 == Version History 383 ; 1.1 : fenders now writen in the form (var ok? ...) accepting zero or many predicates 379 384 ; 1.0.3 : wildcards ommitted, out of hygiene reasons 380 385 ; 1.0.2 : documentation procedure exported
Note: See TracChangeset
for help on using the changeset viewer.