XHarbour - Macro Operator (runtime Compiler)

Macro Operator (runtime Compiler)

One of the most powerful features of the xBase languages is the MACRO Operator '&'. xHarbour’s implementation of the Macro Operator allows for runtime compilation of any valid xHarbour expression. Such compiled expression may be used as a VALUE, i.e. the right side of an Assignment, but more interestingly, such compiled expression may be used to resolve the LEFT side of an assignment, i.e. PRIVATE, or PUBLIC variables, or Database FIELD.

Additionally the Macro Operator may compile and execute function calls, complete assignments, or even list of arguments, and the result of the macro may be used to resolve any of the above contexts in the compiled application. IOW, any xHarbour application may be extended, and/or modified in runtime, to compile and execute additional code on demand.

The xHarbour implementation of this feature is so complete that the xHarbour interpreter, xbScript, uses it heavily, to compile xHarbour scripts.

Syntax:

&( ... )

The text value of the expression '...' will be compiled, and the value resulting from the execution of the compiled code is the result.

&SomeId

is the short form for &( SomeId ).

&SomeId.postfix

is the short form of &( SomeId + "postfix" ).

Read more about this topic:  XHarbour