WebAssembly / WebAssembly/component-model

Package identifier syntax

Open
#231 7 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

While developing a syntax highlighter for WIT, I discovered some sources of confusion (for me at least) regarding package identifiers.

The punctuation symbols in package identifiers (specifically : and .) clash visually with other uses of those same symbols. Examples:

export example:http-client // An export named `example` of type `http-client`
export example:http/client // An export named `client` from the package `example:http`
// The tricky part for me is that one symbol, half-way through a line,
// affects the meaning of what was declared _earlier_ in that line.
// This is awkward to implement in TextMate grammars (which are regex!).


// and:

use example:http/client@1.0.0-beta.nginx.{ request, response }

// It may look like we're "drilling into" some sort of `nginx` submodule
// of the `example:http/client@1.0.0-beta` package, but actually `nginx` is part of the
// semver 'prerelease' component. The actual package id here is: `example:http/client@1.0.0-beta.nginx`
// Moreover, the last period __is__ a "drilling into" period (the one before the curly brace)


One solution could be to enclose package identifiers in quotes like JS and Go do. That way it is immediately clear where the identifier starts and ends, even for developers not intimately familiar with Wit syntax.
Tangentially related; in the example below I've hoisted the interface selector (/client) out of the package name, so that package identifier strings are the same everywhere, regardless of where in the wit file they're used.

export example: http-client  // An export named `example` of type `http-client`
export "example:http".client // An export named `client` from the package `example:http`

// and:

use "example:http@1.0.0-beta.nginx".client.{ request, response }

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 by reading the package-identifier examples in the issue and reviewing the current WIT syntax and its treatment of colons, periods, selectors, and prerelease versions. A decision between the proposed alternatives, followed by corresponding specification changes and validation of the examples, would define done.

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
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.