Use Non-Frames Version Previous Page Next Page
Appendix: DirectCsound

Nested Macros


Macros can be now nested, both in orchestra and score. That is, a previously defined macro can be called from inside another macro definition. When using nested macros, it is recommended to use different names for arguments in the caller and in the target macros, to avoid unpredictable conflicts.

Enabling this feature required a small change in macro argument syntax. Instead of using a '#' character, a ':' character is required in order to separate macro arguments.

Old Syntax

  #define  PLUTO(mikey#minnie#donald)#....body....#         ; old macro definition

  $PLUTO(1#2#3)        ;old macro call

New Syntax (Nested Macros)

  #define  PLUTO( mikey:  minnie:  donald ) # ....body.... #       ; new macro definition

  ;nested macro definition. Notice that the argument names are changed
  #define PIPPO( mik: min: don) #           $PLUTO( 2*$mik :  2+$min :  3 )      $PLUTO( 5:   8:   1 )                 $PLUTO( $mik,$min,3 )           $PLUTO( 1:   2:   $don )              $PLUTO( 4:   5:   6 )            #   ;end of macro

  $PIPPO( 1: 5: 8 )   ; macro call

Comments

It is now possible to comment macros, where before it generated errors.

  ;$PIPPO(1:2:3)

 or

  /*
  $PIPPO(1:2:3)
  */

Comments (both old assembler style ';' and new C-language style '/*...*/') are handled in a special way in macros. Inside a macro body you are allowed to put only old style comments (';'). If you intend to suppress an entire macro without erasing it physically, you can comment it using C-style comments externally ('/* ... */').

The maximum number of macro arguments has been raised to 200. Previously it was five.

N.B. The underscore character '_' has a special purpose in macros. It allows the definition prefixes or suffixes of words, in macro body. Don't use the underscore character in macro names or in macro arguments, or errors will occur. You are allowed to use the underscore in the body of macros, in any case.


Use Non-Frames Version Previous Page Next Page
Appendix: DirectCsound