WebAssembly / WebAssembly/component-model

Inconsistent wit syntax

Open
#254 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
1.4k
Forks
130
Avg merge
2d 1h
Merged PRs (30d)
15

Description

I would like to point at some inconsistency I see in wit syntax, It is not clear to me if there is a good reason or I miss something.

When we define a type, interface, world, resource or importing using use we first write the keyword and then the name, for example:

record pair {
    x: u32,
    y: u32,
}
resource blob {
    constructor(init: list<u8>);
    write: func(bytes: list<u8>);
    read: func(n: u32) -> list<u8>;
    merge: static func(lhs: borrow<blob>, rhs: borrow<blob>) -> blob;
}
interface types {
  enum level {
    info,
    debug,
  }
}
interface console {
  log: func(arg: string);
}
world the-world {
  export test: func();
  export run: func();
}
world my-world {
  import host: interface {
    log: func(param: string);
  }

  export run: func();
}

But when it comes to func or inline interface inside world the syntax changes to the name, a colon and then the keyword. I'm not sure why not to keep the same syntax all the time, so for example it will look like this:

resource blob {
    constructor(init: list<u8>);
    func write(bytes: list<u8>);
    func read(n: u32) -> list<u8>;
    static func merge:(lhs: borrow<blob>, rhs: borrow<blob>) -> blob;
}
interface types {
  enum level {
    info,
    debug,
  }
}
interface console {
 func log(arg: string);
}
world the-world {
  export func test();
  export func run();
}
world my-world {
  import interface host {
    func log(param: string);
  }

  export func run();
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with issue #254 and compare the WIT examples for records, resources, interfaces, worlds, imports, exports, and functions. No files or tests are named, so the next step is to establish whether the syntax should change or whether the existing forms need rationale; done requires an agreed specification direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.