| 1 |
(* By default _import is external *) |
| 2 |
val c_quot = _import "c_quot" private pure: Int8.int * Int8.int -> Int8.int; |
| 3 |
|
| 4 |
(* By default _export is public *) |
| 5 |
val sml_quot = _export "sml_quot": (Int8.int * Int8.int -> Int8.int) -> unit; |
| 6 |
val _ = sml_quot Int8.quot |
| 7 |
|
| 8 |
val call_sml_quot = _import "call_sml_quot" public reentrant: unit -> unit; |
| 9 |
|
| 10 |
val x : Int8.int = ~1 |
| 11 |
val y : Int8.int = 10 |
| 12 |
|
| 13 |
val z = Int8.quot (x, y) |
| 14 |
val c_z = c_quot (x, y) |
| 15 |
|
| 16 |
val bad_z = |
| 17 |
let |
| 18 |
val x : Int8.int = ~1 |
| 19 |
val x : Word8.word = 0wxFF |
| 20 |
val x : Int32.int = Word8.toInt x |
| 21 |
val y : Int8.int = 10 |
| 22 |
val y : Word8.word = 0wx0A |
| 23 |
val y : Int32.int = Word8.toInt y |
| 24 |
val z : Int32.int = Int32.quot (x, y) |
| 25 |
val z = Int8.fromInt z |
| 26 |
in |
| 27 |
z |
| 28 |
end |
| 29 |
|
| 30 |
val () = |
| 31 |
print (concat [" bad_z = ", Int8.toString bad_z, "\n", |
| 32 |
" z = ", Int8.toString z, "\n", |
| 33 |
" c_z = ", Int8.toString c_z, "\n"]) |
| 34 |
val () = call_sml_quot () |