Skip to content

stringref should be non-nullable by default? #47

Open
@wingo

Description

@wingo

The only thing in this proposal that can usefully handle a null stringref is string.eq. This makes me think that the instructions in this proposal should generally consume and produce (ref string), not (ref null string).

It even makes me think that stringref should be a shorthand for (ref string) instead of (ref null string). However all the other shorthands are nullable. My impression is that this is because the other shorthands are abstract; you can use a non-nullable type when you have a little more information on where a value comes from and what you can do with it, but for e.g. externref you can't do anything with it anyway, so it can be nullable, why not. Also, these top types are appropriate for storage locations (table slots etc) which have to be nullable. So I see the reason for e.g. externref to be nullable but I don't necessarily think it applies to stringref, which is a concrete type.

Options:

  1. Leave as is: instructions consume nullable types. (Though, we recently changed instructions that produce stringref values to make non-nullable types; string.new*, string.const, string.concat should produce non-nullable results #42.)
  2. Change everything except string.eq to take (ref string), (ref stringview_wtf8), and so on: non-nullable types.
  3. (2), but also change stringref to be shorthand for (ref string) instead of (ref null string).
  4. (2), and remove the stringref (and stringview_wtf8, etc) shorthands. Just use the two-byte ref forms.

Thoughts?

Related to #42, #18, and #14.

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