next up previous contents
Next: Co-routining Up: ale_trale_ref Previous: ALE Lexical Rule Compilation   Contents


Logical Variable Macro Compilation

[User's Manual]
[Code]
As discussed in the User's Guide, TRALE's logical-variable macros (unlike ALE macros) assume structure-sharing of their variables if they are used more than once in the definition of the macro. What TRALE does during compilation of logical-variable macros is simply translate into ALE macros such that structure-sharing between variables is preserved. For example, the following logical-variable macro

foo(X,Y) := f:X, g:X, h:Y.
is translated into
foo(X,Y) macro f:(X,_A), g:(X,_A), h:(Y,_B).
The added variables _A and _B are there to enforce structure sharing among multiple occurrences of the logical-variable macros X and Y. If a guard declaration is given in the definition of the logical-variable macro to restrict the type of the variables, then that is translated as a description as in the following example:
foo(X-a,Y-b) := f:X, g:X, h:Y

foo(X,Y) macro f:(X,a,_A), g:(X,a,_A), h:(Y,b,_B)
To reiterate, the added variables _A and _B make ALE treat the variables in the right-hand side not as logical variables but as normal Prolog variables.

Let us now see how TRALE performs this translation. First, TRALE gathers all :=/2 predicates (logical-variable macros) in a list and hands them to compute_macros/2 which in turn goes through each macro one by one generating left-hand side arguments for a corresponding macro/2 definition with the same predicate name and arity as the left-hand side of the original :=/2. The descriptions used as arguments in the new left-hand side, however, are provided by add_lv_macro_descs/4.


next up previous contents
Next: Co-routining Up: ale_trale_ref Previous: ALE Lexical Rule Compilation   Contents
TRALE Reference Manual