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.

[js-api] DefaultValue needs updating #501

Closed

Description

@rossberg

The DefaultValue algorithm needs updating to handle more general reference types. Moreover, it is partial now, so all use sites need to adapt to the possibility of it failing.

@takikawa

Also, this algorithm is unrelated to JS and in fact duplicates the respective definition in the core spec. It might be preferable to expose that in the core spec's embedding interface and call into that.

Activity

  1. eqrion commented on Dec 20, 2023

    @eqrion
    Contributor

    Also, this algorithm is unrelated to JS and in fact duplicates the respective definition in the core spec. It might be preferable to expose that in the core spec's embedding interface and call into that.

    The JS-API default value function is slightly different than wasm's default value function. JSAPI-DefaultValue(externref) = undefined, while Wasm-DefaultValue(externref) = null. This is thanks to JS filling in missing parameters with undefined.

  2. rossberg commented on Dec 21, 2023

    @rossberg
    MemberAuthor

    Fair enough, but it would still be preferable to handle only this special case here and then defer to the core spec for all regular cases.

    (Although personally I still think this special case is odd and instead it should only use undefined if explicitly given, not as default. There is precedence in JS for treating an absent parameter differently from explicit undefined, e.g., [].reduce(() => 0) throws TypeError, whereas [].reduce(() => 0, undefined) returns undefined.)

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

Metadata

Metadata

Assignees

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