Sun Aug 19 15:27:10 CEST 2007
What are constants? Phase separation violation! In contrast to normal
macros, which obey separation because they do not use any values
created at compile time, macros generated by 'constant' join 2 phases.
The 'constant' word could be termed a "phase fold". The compiler after
'constant' is not the same one as before: it is extended with a
This kind of behaviour prevents modularization of code, because it is
not clear what the definition of the new macro depends on, the only
thing that can be assumed is that it depends on all the previous code,
and that all the following code depends on the new macro.
The solution is that this behaviour needs to be unrolled: instead of
updating the compiler on the fly, an extention phase (where macros are
defined) needs to preceed a compilation phase (where macros are
There is a general way to unroll 'constant': split the code in 3
parts: the part before, the definition of the new macro, and the code
after. This is rather cumbersome and entirely unnecessary..
However, in the case of Purrr18 it is usually possible in to transform
the code to a macro definition. Instead of writing
1 1 + constant twee
one could write
macro : twee 1 1 + ; forth
This enables the macro definition to be distinguished from the rest of
the code, to clarify the dependencies of a file's plain code on the
macros defined in that file.
The only reason not to do it the second way is because it looses the
name 'twee' in the eventual assembly code.
Removing 'constant' could lead to a better transparency in the code:
compiled macros could then be seen as 'only cache'.
Note that i would do this just for more transparency, not to eliminate
undefined symbols: macro name binding is still late.