About your reference example:
Code: Select all
#macro assign( sym, expr )
#define tmp __FB_EVAL__( expr )
__FB_UNQUOTE__( __FB_EVAL__( "#undef " + sym ) )
__FB_UNQUOTE__( __FB_EVAL__( "#define " + sym + " " + __FB_QUOTE__( tmp ) ) )
#undef tmp
#endmacro
#define x
assign( "x", 1 )
print x '' 1
assign( "x", x+1 )
print x '' 2
assign( "x", cos(1/x) )
print x '' 0.877..
assign( "x", "hello" )
print x '' hello
assign( "x", x+x )
print x '' hellohello
Code: Select all
#macro assign( sym, expr )
__FB_UNQUOTE__( __FB_EVAL__( "#undef " + sym ) )
__FB_UNQUOTE__( __FB_EVAL__( "#define " + sym + " " + __FB_QUOTE__( expr ) ) )
#endmacro
#define x
assign( "x", 1 )
print x '' 1
assign( "x", x+1 )
print x '' 2
assign( "x", cos(1/x) )
print x '' 0.877..
assign( "x", "hello" )
print x '' hello
assign( "x", x+x )
print x '' hellohello
[edit]
Wrong remark (see my next post).