WebAssembly / WebAssembly/component-model
Inconsistent wit syntax
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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