Tuesday, December 05, 2006

Macros!

We now have macros.

Files with macros, are included with compile_once() (which handles preprocessing, as well as smart recompiling).

Then, macros are used like this:

#check is_array($x)#

that is, they are surrounded by "#", and have the name of the macro, and the parameters.

To define a macro, just define the macro handler function:

function check($code){
if (defined('assertions')) {
return "assert($code);"
} else {
return '';
}
}

Macro function return compilable code (a string) based on the input string.

Labels:

0 Comments:

Post a Comment

<< Home