Artifact Content
Not logged in

Artifact a38c7267da8f14a3fb155a7f385dae92c269f477


@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) {
  @v(
    def pow(x, n) {
      if( n == 1 ) { x }
      else {
        @macro( @v(x) * @v(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()