Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Motivation for externref <: anyref #143

Description

@RossTate

#130 and #142 identify some disadvantages to having externref be a subtype of anyref. I am wondering what the advantages are. Note that, after upcasting externrefs to anyrefs, there is no reliable way to downcast the resulting anyrefs back to externrefs, making the subtyping a one-way street. Consequently, it seems to me that a module mixing externrefs with its own values (uniformly represented as anyrefs) would want to box the externrefs in some manner, both to provide a way to later unbox them and to prevent bugs that could be caused by unintended/unanticipated overlaps between externref values and the module's own values. This boxing pattern would not need externref to be a subtyping of anyref. And if the boxing pattern is indeed common and we leave externref as a subtype of anyref, then that would mean that foreign references would first get boxed to become externrefs that are compatible with anyrefs, which would then get boxed again by the application, and then the reverse for unboxing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions