Artifact 274d10aca22ce25f8b3e97da9c868e8c30bbd2bb
@macro twice(x) { x; x };
@macro max(x,y) {
var _x = x; # no hygenic macro btw....
var _y = y; # no hygenic macro btw....
if(_x<_y){_y}else{_x}
};
def maxNormal(x,y) {
if(x<y){y}else{x}
};
@macro maxBad(x,y) {
if(x<y){y}else{x}
};
@macro LetItBe(x, y) { let it = x in y };
@macro pow10(x) {
@value(
def pow(x, n) {
if( n == 1 ) { x }
else {
@macro( @value(x) * @value(pow(x,n-1)) )
}
}
in
pow(@macro(x),10)
)
};
def printAndReturn(x)
{
print(x);
x
};
def main()
{
twice( print("foo") );
print("--------------");
print(max(printAndReturn(100),printAndReturn(200)));
print("--------------");
print(maxNormal(printAndReturn(100),printAndReturn(200)));
print("--------------");
print(maxBad(printAndReturn(100),printAndReturn(200)));
print("--------------");
print( LetItBe( 1+2+3, it*it ) );
print("--------------");
print(pow10(2));
};
main()