[wg-camlp4] My uses of syntax extension
Alain Frisch
alain at frisch.fr
Tue Jan 29 11:37:33 GMT 2013
On 01/28/2013 10:55 PM, Gerd Stolpmann wrote:
> Here is a recent code snippet from me:
>
> let func =
> IFDEF SAFE THEN
> ctx.functions_7.(func_idx)
> ELSE
> Array.unsafe_get ctx.functions_7 func_idx
> ENDIF in
>
> i.e. just a fine-grained version of -unsafe. Of course, I can use
> (local) structures here as well, but the whole point is to speed the
> code up once you are sure the code is SAFE.
Yes, we can come up with a syntax for conditional compilation an
expressions as well. For instance:
if DEF(SYMBOL) then e1 else e2
> Macros - in the general sense - would be better handled on the level of
> tokens. That said, we could also do this by a normal -pp preprocessor
> (these are run _before_ -ppx, right?).
Yes, but be careful that -pp preprocessors cannot be chained (they map
concrete syntax to abstract one).
-- Alain
More information about the wg-camlp4
mailing list