Allow table.copy between tables with different index types#58
Conversation
interpreter/syntax/types.ml
Outdated
| | ExternGlobalType gt1, ExternGlobalType gt2 -> match_global_type gt1 gt2 | ||
| | _, _ -> false | ||
|
|
||
| let min_index_type it1 it2 = |
There was a problem hiding this comment.
I don't think this function is needed, you ought to be able to just use OCaml's polymorphic min function.
There was a problem hiding this comment.
Interesting. That does seem to work.
I though I32IndexType and I64IndexType were just essentially enum values that make up the index_type type. How does ocaml know how to compile them in functions like min?
There was a problem hiding this comment.
OCaml uses a uniform representation, so can have a single polymorphic implementation for an operator like <= that works for arbitrary values. Though here the operand type is monomorphic and compiled to int, so the compiler probably specialises that to an int comparison after inlining min.
There was a problem hiding this comment.
But I don't see I32IndexType and I64IndexType defined as integer constants anywhere. I must be missing something obvious here.. Is ocaml simply assigned numbers to them like an enum in C?
There was a problem hiding this comment.
It compiles them to numbers in order of appearance. But unlike in C that's just an implementation detail and not observable, only their order is.
See #7 See #6