Contents | Index | < Browse | Browse >
2.10 Macros

  A macro is a definition of text that is inserted during compilation time
  whenever the name of the macro is stated. In AmiBlitz³, they are defined
  by the "MACRO" Compiler directive and and referred by using a
  leading "!" (exclamation mark).
  A macro can have parameters, they are reference by `n (Back Quote + param#)
  within the macro.
 
  +-----------------------------------------------------------------------------
  | 
  | MACRO myIntConst    :             5 : End MACRO
  | MACRO myFloatConst  :           5.4 : End MACRO
  | MACRO myStringConst :        "Test" : End MACRO
  | MACRO myFuncMacro   : ((`1) * (`2)) : End MACRO
  | 
  | Print !myStringConst,!myFuncMacro{2,3}
  |  
  | ; The compiler would see: Print "Test",((2) * (3))
  | 
  +-----------------------------------------------------------------------------
  Note: The Print would output "Test6".

  A disadvantage of Macros is, that they are typeless.
  Mismatching types are determined AFTER the macro is applied, which makes
  debugging harder.

  Useful macros found in all.res:
  
  Symbol         | Description
  ---------------+--------------------------------------------------------------
  !version       | version string

  Useful macros found in "useful.include.bb2"

  Symbol         | Description
  ---------------+--------------------------------------------------------------
  !_NULL         | 0, Null pointer to make source more readable  
  !_ASSERT{x}    | terminates the program with an error message if x is false/0
  

Contents | Index | < Browse | Browse >