[MLton] patch for CM cc variable support?

Tom 7 twm@andrew.cmu.edu
Mon, 13 Feb 2006 17:47:01 -0500 (EST)


This works fine, thanks!

Somehow I led myself to believe that the defined() mechanism was only for 
SML identifiers, and missed the use for CM variables (and the mlton page 
describing this). Oops..

I don't care about CM compatibility, I just wanted some way to maintain 
fewer files for small projects. Since that already exists, I withdraw 
my requests! =)

  Tom

>
>> 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?
>
>


[ NEW! : http://tom7.org/       ]
[ OLD! : http://fonts.tom7.com/ ]