Can CM detect MLton vs. SML/NJ?

Matthew Fluet fluet@CS.Cornell.EDU
Tue, 16 Oct 2001 12:56:43 -0400 (EDT)


> > Do you know if CM can detect whether I'm compiling with
> > MLton or with SML/NJ? 
> 
> Yes.  MLton doesn't define any preprocessor symbols with CM, so the following
> should work.
> 
> # if ( defined (SMLNJ_VERSION) )
> 
> (* SML/NJ stuff here *)
> 
> # else
> 
> (* MLton stuff here *)
> 
> # endif

But, I think that Anoq was concerned about when cmcat is running.  I don't
think there is any natural way of distinguishing between them -- in
particular, after running cmcat to get a list of files, nothing prevents
me from feeding that list to either MLton or SML/NJ.

What might be better is a hack of cmcat that allowed you to register
preprocessor symbols with CM from the command line, something like
cmcat -DMLton foo.cm

Then you could use
#if (defined(MLton))
 (* MLton stuff *)
#else
 (* SML/NJ stuff *)
#endif
in your cm files and different invocations of cmcat would produce the
different results.