Phil Clayton
2017-12-21 23:34:59 UTC
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
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