With reference types, function references, exceptions and GC there are multiple proposals in flight currently that introduce or concretise heap types, and I'd like to understand the relationship the new types will have in the whole picture.
There are the extern and func heap types coming from reference types, and the exn heap type from exception handling. GC introduces any, eq and i31 on top, establishing the following subtyping relationship:
โโโโโโโผโโโโโฌโโโโโโ
extern func eq exn
โ โ
signature* โ
โ
โโโโโโโผโโโโโโโโโ
i31 struct* array*
with
signature* being a concrete functionstruct* being a concrete structarray* being a concrete arrayWhat I am not sure about is:
extern a subtype of eq?extern?exn a subtype of eq?Or is there perhaps something fundamentally wrong in my understanding?
The graph you've drawn matches my understanding.
externref is the new name for what used to be called anyref, and back then intentionally didn't support equality checking, so I'd assume that it continues to not be a subtype of eqref. I further assume that it won't have any subtypes, because by virtue of being an "external" reference, it's opaque to Wasm. (That said, it's conceivable that we may want to allow subtype hierarchies of opaque external references; AFAIK no such proposal is in flight yet; and the use case might be subsumed by the type-imports proposal.)
My understanding is that the exceptions proposal is debating changes that would drop the exnref type.
And you're probably aware that within this GC proposal, there's some debate around i31, so that might change in the future as well.
externrefis the new name for what used to be calledanyref, and back then intentionally didn't support equality checking, so I'd assume that it continues to not be a subtype ofeqref. I further assume that it won't have any subtypes, because by virtue of being an "external" reference, it's opaque to Wasm. (That said, it's conceivable that we may want to allow subtype hierarchies of opaque external references; AFAIK no such proposal is in flight yet; and the use case might be subsumed by the type-imports proposal.)
Does this mean that GC will no longer have an anyref type? Or that GC's anyref type is different from the anyref-now-externref previously mentioned in reference types?
Does this mean that GC will no longer have an anyref type?
This GC proposal has an anyref type, which is an alias for (ref null any). It also has an externref type that is an alias for (ref null extern). They are different types, and AIUI extern <: any, as described above.
Thanks for the clarification.