[MLton] SML vs. the C preprocessor
Matthew William Cox
matt at mattcox.ca
Tue Jul 17 10:25:23 PDT 2007
On Tue, Jul 17, 2007 at 01:35:39PM +0200, Wesley W. Terpstra wrote:
> Do other people miss __FILE__ and __LINE__? Does anyone see a way of
> getting similar functionality?
IIRC, __FILE__ and __LINE__ are injected by the C preprocessor. The
obvious thing to do would be to run the CPP on your SML sources. This
would be a pain to do by hand, but maybe you could
a) Write a makefile that has an implicit rule to build .sml
files from .smlpp. You'll need a sed pass on the file to
eliminated some debris left behind on the processed file.
b) Hack the mlton driver to use CPP to process .smlpp files by
preprocessing. You'd probably have to fiddle with the lexer
as well, since the CPP leaves some artifacts like # file
directives to allow the compiler to give better error
reporting on where a troublesome construct originated from.
Matt
More information about the MLton
mailing list