Differences From Artifact [99466484fdc29835]:
- File
sample/macro.pmy
- 2010-11-26 15:13:58 - part of checkin [6760e0dd02] on branch trunk - evaluator refactoring done. x6 speed up. (user: kinaba) [annotate]
To Artifact [fe180b545227dcde]:
- File
sample/macro.pmy
- 2010-11-27 12:49:03 - part of checkin [a795c97dc3] on branch trunk - changed Let.init to Let.vdef. IT IS VERY DANGEROUS TO USE .init MEMBER NAME in D!!!!!!!! (user: kinaba) [annotate]
19 19 if x<y then y else x
20 20 };
21 21 @macro maxGreat(x,y){@value(
22 22 var nx = gensym(); # generate fresh symbol
23 23 var ny = gensym();
24 24 @macro _x = @macro(nx) {name: nx}; # cheating to create {is:"Var" .. }
25 25 @macro _y = @macro(ny) {name: ny}; # at macro layer
26 - {is: "Let", name: nx, layer: "", init: @macro(x), expr:
27 - {is: "Let", name: ny, layer: "", init: @macro(y), expr:
26 + {is: "Let", name: nx, layer: "", vdef: @macro(x), expr:
27 + {is: "Let", name: ny, layer: "", vdef: @macro(y), expr:
28 28 @macro(if _x < _y then _y else _x)}} # the expression
29 29 )};
30 30
31 31 print( maxGood(print(1), print(2)) ); # 1 2 2
32 32 print( maxBad(print(1), print(2)) ); # 1 2 2 2
33 33 print( maxFun(print(1), print(2)) ); # 1 2 2
34 34 print( maxGreat(print(1), print(2)) ); # 1 2 2