Differences From Artifact [977cd2f997805f91]:
- File
sample/macro.pmy
- 2010-11-23 18:28:47 - part of checkin [ba11f1d551] on branch trunk - fixed the macro scoping rules concerning non-macro let (user: kinaba) [annotate]
To Artifact [b31646ec7576a8a6]:
- File
sample/macro.pmy
- 2010-11-24 12:14:00 - part of checkin [3ae09b8cbf] on branch trunk - changed if-then-else syntax (user: kinaba) [annotate]
1 1 @macro twice = fun(x) { x; x };
2 2 @macro max(x,y) {
3 3 var _x = x; # no hygenic macro btw....
4 4 var _y = y; # no hygenic macro btw....
5 - if(_x<_y){_y}else{_x}
5 + if(_x<_y)then _y else _x
6 6 };
7 7 def maxNormal(x,y) {
8 - if(x<y){y}else{x}
8 + if(x<y)
9 + then: y
10 + else: x
9 11 };
10 12 @macro maxBad(x,y) {
11 - if(x<y){y}else{x}
13 + if x<y: y else: x
12 14 };
13 15
14 16 @macro LetItBe(x, y) { let it = x in y };
15 17
16 18 @macro pow10(x) {
17 19 @value(
18 20 def pow(y, n) {
19 - if( n == 1 ) { y }
20 - else {
21 + if( n == 1 ) then y
22 + else
21 23 @macro( @value(y) * @value(pow(y,n-1)) )
22 - }
23 24 }
24 25 in
25 26 pow(@macro(x+1),10)
26 27 )
27 28 };
28 29
29 30 @macro pow10Hard(x) {
30 31 @value(
31 32 def pow(x, n) {
32 - if( n == 1 ) { x }
33 - else {
33 + if( n == 1 ) then x
34 + else
34 35 @macro( @value(x) * @value(pow(x,n-1)) )
35 - }
36 36 }
37 37 in
38 38 pow(@macro(x+1),10)
39 39 )
40 40 };
41 41
42 42 def printAndReturn(x)