Artifact Content
Not logged in

Artifact a38c7267da8f14a3fb155a7f385dae92c269f477


     1  @macro twice(x) { x; x };
     2  @macro max(x,y) {
     3    var _x = x; # no hygenic macro btw....
     4    var _y = y; # no hygenic macro btw....
     5    if(_x<_y){_y}else{_x}
     6  };
     7  def maxNormal(x,y) {
     8    if(x<y){y}else{x}
     9  };
    10  @macro maxBad(x,y) {
    11    if(x<y){y}else{x}
    12  };
    13  
    14  @macro LetItBe(x, y) {
    15    let it = x in y
    16  };
    17  
    18  @macro pow10(x) {
    19    @v(
    20      def pow(x, n) {
    21        if( n == 1 ) { x }
    22        else {
    23          @macro( @v(x) * @v(pow(x,n-1)) )
    24        }
    25      }
    26      in
    27        pow(@macro(x),10)
    28    )
    29  };
    30  
    31  def printAndReturn(x)
    32  {
    33  	print(x);
    34  	x
    35  };
    36  
    37  
    38  
    39  
    40  
    41  def main()
    42  {
    43  	twice( print("foo") );
    44  	print("--------------");
    45  	print(max(printAndReturn(100),printAndReturn(200)));
    46  	print("--------------");
    47  	print(maxNormal(printAndReturn(100),printAndReturn(200)));
    48  	print("--------------");
    49  	print(maxBad(printAndReturn(100),printAndReturn(200)));
    50  	print("--------------");
    51  	print( LetItBe( 1+2+3, it*it ) );
    52  	print("--------------");
    53  	print(pow10(2));
    54  };
    55  
    56  main()