As well as PolyML.rtsVersion there are also PolyML.Compiler.compilerVersion and PolyML.Compiler.compilerVersionNumber. This last is probably the best way of determining whether you have 5.6 or 5.7.

In this case, though, presumably you are really looking to see whether "int" is LargeInt.int or not. You could use Foreign.cUint64 in 5.7 if Poly/ML was built with arbitrary precision as default. Could you not look at Int.maxInt and use that to decide if you need to use Foreign.cUint64Large ?

David

On 21/12/2017 23:34, Phil Clayton wrote:
I am trying to define LargeInt.int conversions for C integer types in terms of those supplied in Foreign in a way that will work with both Poly/ML 5.6 or 5.7.  This requires that e.g.
   - Foreign.cUint64 is used for Poly/ML = 5.6 but
   - Foreign.cUint64Large is used for Poly/ML >= 5.7
I am thinking of achieving this by having separate SML files for different Poly/ML versions and using the right one as follows:

   let
     val version = PolyML.rtsVersion ()
   in
     PolyML.use (
       if version >= 570
       then "src-5.7.sml"
       else if version = 560
       then "src-5.6.sml"
       else raise Fail "unsupported Poly/ML version"
     )
   end

Is this a future-proof way to choose based on Poly/ML version?

Another option might be to copy the implementation of these conversions from Foreign.sml but that may not be possible - for example I couldn't see how to get the flag bigEndian in an application.

Is there a better way altogether with some compiler trickery?

Phil

_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to