[MLton] The evils of importing as 'extern'

Wesley W. Terpstra wesley@terpstra.ca
Wed, 24 May 2006 17:10:57 +0200


I needed to include basis-ffi.h in c-chunk.h in order to get  
prototypes for WordS8_quot, because Word-check.h had methods which  
inferred an incorrect type. This then later conflicted with the  
correct type signature that MLton wrote in the c-codegen. By  
including basis-ffi.h, this problem was fixed as Word-check.h no  
longer needed to infer the type, as the (correct) prototype was  
already available.

However, now we have the problem that basis-ffi.h correctly defines  
Real64_Math_e as a Real64_t. Unfortunately, the C codegen doesn't  
output the type, just an 'extern Real64_Math_e;'. My original FFI  
changes output 'extern Real64_t Real64_Math_e;' which would've worked  
here.

Somewhere that code got lost in the argument about whether it was  
important that _address also provide a correct type. I propose to  
resurrect this change for _symbol. For the basis, at least, the type  
information which _symbol has will suffice. _address can continue to  
emit 'extern X', though I personally still think we'd have been  
better off if _address had included the pointed-to type too.

Comments?