Skip to content

Use typeuse in text format? #144

@tlively

Description

@tlively

The current explainer does not explicitly explain the text format for this proposal, but I propose that the text format for continuation type definitions be updated to this:

comptype_I ::= ... | '(' 'cont' (x,I'):typeuse_I ')' => (cont x), I'

Using the existing typeuse production and its abbreviation would allow all of these to be well-formed and valid:

(module
  (type $f (func (param i32) (result i32))
  (type $k1 (cont (type $f)))
  (type $k2 (cont (type $f) (param i32) (result i32))) ;; Same as $k1
  (type $k3 (cont (param i32) (result i32))) ;; Same as $k1 and $k2
  (type $k4 (cont (param i64) (result i64))) ;; Implicitly defines a new function type
  (type $k5 (cont)) ;; Implicitly defines a new function type
)

Notably the current text format (type $k (cont $f)) would no longer be correct, but the advantage would be that writing tests would become much simpler because the function types would not need to be separately defined. (This is about the text format only; the function type definition would still be separate in the binary format and abstract syntax.)

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