[MLton] patch for CM cc variable support?
Stephen Weeks
MLton@mlton.org
Mon, 13 Feb 2006 14:38:08 -0800
> May I request this small change to the way that CM works in mlton?
> Right now, there are no defined symbols whatsoever, . which (as far
> as I can tell) makes it impossible to use the conditional
> compilation system to make a CM file that works with both mlton and
> the newest sml/nj.
According to http://mlton.org/CompilationManager, the following should
work. I just checked, and indeed it does.
In SML/NJ, the preprocessor defines the symbol SMLNJ_VERSION. In
MLton, no symbols are defined. So, to conditionally include foo.sml
when compiling under SML/NJ, one can use the following pattern.
# if (defined(SMLNJ_VERSION))
foo.sml
# endif
To conditionally include foo.sml when compiling under MLton, one can
negate the test.
# if (! defined(SMLNJ_VERSION))
foo.sml
# endif
> It might also make sense to modify line 408 of lexer.sml to return
> SOME 0 for undefined symbols, as SML/NJ apparently does.
I guess you mean line 404? I have no strong objection to such a
change, if that's what people in the CM world would expect. But I
worry that such a change would cause more confusion than reporting an
error, as conditionals would be silently taken (or not). Since MLton
doesn't define any variables, I don't really see the use for such a
thing, or any useful overlap with SML/NJ. Also, with the above idiom,
it should be possible to wrap stuff that uses SML/NJ CM variables so
that it only runs under SML/NJ, right? Anyone else have any thoughts?