2.7. Identifier Macros

A identifier macros represent names. They replace names in expressions and most declarations, including the name of a function or variable being defined. Names are not replaced in type expressions, patterns, or regular expressions.

The special form in which the RHS name is called 'new' creates a fresh, previously unused name.

Unlike other macros, the RHS name of an ident macro is not expanded at the point of definition.

On use, the value of an ident macro is the first name in the chain which is not an ident macro, or which recurs.

Start felix section to tut/examples/mac128.flx[1 /1 ]
     1: #line 554 "./lpsrc/flx_tut_macro.pak"
     2: #include <flx.flxh>
     3: 
     4: macro oldname is newname;
     5: fun oldname(x:int):int = { return x; }
     6: print (newname 1); endl;
     7: 
     8: macro proc make_ints ()
     9: {
    10:   macro vnew is new;
    11:   val vnew = vold+1;
    12:   macro vold = vnew;
    13: }
    14: 
    15: val x = 1;
    16: 
    17: macro var vold = x;
    18: make_ints;
    19: make_ints;
    20: make_ints;
    21: print vold; endl;
    22: 
End felix section to tut/examples/mac128.flx[1]


2.7.1. Forgetting Macros
2.7.2. For Loops
2.7.3. Unpacking Tuples
2.7.4. String representation
2.7.5. Packing Tuples