You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a follow-up to #249 and discussion in today's component model
meeting to require semicolons after the `package` statement to ensure
it's consistent with all other "single line things" in the WIT format.
Copy file name to clipboardExpand all lines: design/mvp/WIT.md
+36-36Lines changed: 36 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -46,13 +46,13 @@ Package identifiers are specified at the top of a WIT file via a `package`
46
46
declaration:
47
47
48
48
```wit
49
-
package wasi:clocks
49
+
package wasi:clocks;
50
50
```
51
51
52
52
or
53
53
54
54
```wit
55
-
package wasi:clocks@1.2.0
55
+
package wasi:clocks@1.2.0;
56
56
```
57
57
58
58
WIT packages can be defined in a collection of files and at least one of them
@@ -74,7 +74,7 @@ belong to an interface.
74
74
An example of an interface is:
75
75
76
76
```wit
77
-
package local:demo
77
+
package local:demo;
78
78
79
79
interface host {
80
80
log: func(msg: string);
@@ -98,7 +98,7 @@ An `interface` can contain [`use`][use] statements, [type][types] definitions,
98
98
and [function][functions] definitions. For example:
99
99
100
100
```wit
101
-
package wasi:filesystem
101
+
package wasi:filesystem;
102
102
103
103
interface types {
104
104
use wasi:clocks.wall-clock.{datetime};
@@ -135,7 +135,7 @@ equivalent of a `component` type in the component model. For example this
135
135
world:
136
136
137
137
```wit
138
-
package local:demo
138
+
package local:demo;
139
139
140
140
world my-world {
141
141
import host: interface {
@@ -165,7 +165,7 @@ Worlds can contain any number of imports and exports, and can be either a
165
165
function or an interface.
166
166
167
167
```wit
168
-
package local:demo
168
+
package local:demo;
169
169
170
170
world command {
171
171
import wasi:filesystem/filesystem;
@@ -187,7 +187,7 @@ Additionally interfaces can be defined inline with an explicit kebab-name that
187
187
avoids the need to have an out-of-line definition.
188
188
189
189
```wit
190
-
package local:demo
190
+
package local:demo;
191
191
192
192
interface out-of-line {
193
193
the-function: func();
@@ -209,7 +209,7 @@ In the component model imports to a component either use an ID or a
209
209
kebab-name, and in WIT this is reflected in the syntax:
210
210
211
211
```wit
212
-
package local:demo
212
+
package local:demo;
213
213
214
214
interface my-interface {
215
215
// ..
@@ -243,7 +243,7 @@ A World can be created by taking the union of two or more worlds. This operation
243
243
Below is a simple example of a world that includes two other worlds.
244
244
245
245
```wit
246
-
package local:demo
246
+
package local:demo;
247
247
248
248
// definitions of a, b, c, foo, bar, baz are omitted
249
249
@@ -283,7 +283,7 @@ world union-my-world {
283
283
The `include` statement also works with [WIT package](#wit-packages-and-use) defined below with the same semantics. For example, the following World `union-my-world-a` is equivalent to `union-my-world-b`:
284
284
285
285
```wit
286
-
package local:demo
286
+
package local:demo;
287
287
288
288
interface b { ... }
289
289
interface a { ... }
@@ -313,7 +313,7 @@ world union-my-world-b {
313
313
If two worlds shared the same set of import and export IDs, then the union of the two worlds will only contain one copy of this set. For example, the following two worlds `union-my-world-a` and `union-my-world-b` are equivalent:
314
314
315
315
```wit
316
-
package local:demo
316
+
package local:demo;
317
317
318
318
world my-world-a {
319
319
import a1;
@@ -342,7 +342,7 @@ When two or more included Worlds have the same name for an import or export that
342
342
The following example shows how to resolve name conflicts where `union-my-world-a` and `union-my-world-b` are equivalent:
343
343
344
344
```wit
345
-
package local:demo
345
+
package local:demo;
346
346
347
347
world world-one { import a: func(); }
348
348
world world-two { import a: func(); }
@@ -361,7 +361,7 @@ world union-my-world-b {
361
361
`with` cannot be used to rename IDs, however, so the following world would be invalid:
362
362
363
363
```wit
364
-
package local:demo
364
+
package local:demo;
365
365
366
366
interface a {
367
367
foo: func();
@@ -403,7 +403,7 @@ A `use` statement inside of an `interface` or `world` block can be used to
403
403
import types:
404
404
405
405
```wit
406
-
package local:demo
406
+
package local:demo;
407
407
408
408
interface types {
409
409
enum errno { /* ... */ }
@@ -425,7 +425,7 @@ Interfaces linked with `use` must be acyclic.
425
425
Names imported via `use` can be renamed as they're imported as well:
426
426
427
427
```wit
428
-
package local:demo
428
+
package local:demo;
429
429
430
430
interface my-host-functions {
431
431
use types.{errno as my-errno};
@@ -447,7 +447,7 @@ interface types {
447
447
}
448
448
449
449
// host.wit
450
-
package local:demo
450
+
package local:demo;
451
451
452
452
interface my-host-functions {
453
453
use types.{errno, size};
@@ -462,7 +462,7 @@ the same syntax is used in `import` and `export` directives:
462
462
463
463
```wit
464
464
// a.wit
465
-
package local:demo
465
+
package local:demo;
466
466
467
467
world my-world {
468
468
import host;
@@ -484,7 +484,7 @@ When referring to an interface an ID form can additionally be used to refer to
484
484
dependencies. For example above it was seen:
485
485
486
486
```wit
487
-
package local:demo
487
+
package local:demo;
488
488
489
489
world my-world {
490
490
import wasi:clocks/monotonic-clock;
@@ -497,7 +497,7 @@ This is the package identified by `wasi:clocks` and the interface
497
497
well:
498
498
499
499
```wit
500
-
package local:demo
500
+
package local:demo;
501
501
502
502
interface my-interface {
503
503
use wasi:http/types.{request, response};
@@ -510,7 +510,7 @@ If a package being referred to has a version number, then using the above syntax
510
510
so far it can get a bit repetitive to be referred to:
511
511
512
512
```wit
513
-
package local:demo
513
+
package local:demo;
514
514
515
515
interface my-interface {
516
516
use wasi:http/types@1.0.0.{request, response};
@@ -528,7 +528,7 @@ interfaces within the scope of the file itself. For example the above could be
528
528
rewritten as:
529
529
530
530
```wit
531
-
package local:demo
531
+
package local:demo;
532
532
533
533
use wasi:http/types@1.0.0;
534
534
use wasi:http/handler@1.0.0;
@@ -550,7 +550,7 @@ The interface referred to by a `use` is the name that is defined in the current
550
550
file's scope:
551
551
552
552
```wit
553
-
package local:demo
553
+
package local:demo;
554
554
555
555
use wasi:http/types; // defines the name `types`
556
556
use wasi:http/handler; // defines the name `handler`
@@ -560,7 +560,7 @@ Like with interface-level-`use` the `as` keyword can be used to rename the
560
560
inferred name:
561
561
562
562
```wit
563
-
package local:demo
563
+
package local:demo;
564
564
565
565
use wasi:http/types as http-types;
566
566
use wasi:http/handler as http-handler;
@@ -570,7 +570,7 @@ Note that these can all be combined to additionally import packages with
570
570
multiple versions and renaming as different identifiers.
571
571
572
572
```wit
573
-
package local:demo
573
+
package local:demo;
574
574
575
575
use wasi:http/types@1.0.0 as http-types1;
576
576
use wasi:http/types@2.0.0 as http-types2;
@@ -589,7 +589,7 @@ component.
589
589
For example this document:
590
590
591
591
```wit
592
-
package local:demo
592
+
package local:demo;
593
593
594
594
interface shared {
595
595
record metadata {
@@ -646,7 +646,7 @@ Functions are defined in an [`interface`][interfaces] or are listed as an
646
646
be named and have unique names:
647
647
648
648
```wit
649
-
package local:demo
649
+
package local:demo;
650
650
651
651
interface foo {
652
652
a1: func();
@@ -658,7 +658,7 @@ interface foo {
658
658
Functions can return at most one unnamed type:
659
659
660
660
```wit
661
-
package local:demo
661
+
package local:demo;
662
662
663
663
interface foo {
664
664
a1: func() -> u32;
@@ -669,7 +669,7 @@ interface foo {
669
669
And functions can also return multiple types by naming them:
670
670
671
671
```wit
672
-
package local:demo
672
+
package local:demo;
673
673
674
674
interface foo {
675
675
a: func() -> (a: u32, b: float32);
@@ -688,7 +688,7 @@ time. The types supported in WIT is the same set of types supported in the
688
688
component model itself:
689
689
690
690
```wit
691
-
package local:demo
691
+
package local:demo;
692
692
693
693
interface foo {
694
694
// "package of named fields"
@@ -867,7 +867,7 @@ WIT files optionally start with a package declaration which defines the ID of
867
867
the package.
868
868
869
869
```ebnf
870
-
package-decl ::= 'package' ( id ':' )+ id ( '/' id )* ('@' valid-semver)?
870
+
package-decl ::= 'package' ( id ':' )+ id ( '/' id )* ('@' valid-semver)? ';'
871
871
```
872
872
873
873
The production `valid-semver` is as defined by
@@ -1406,7 +1406,7 @@ An example of the binary format is that this document:
1406
1406
1407
1407
```wit
1408
1408
// host.wit
1409
-
package local:demo
1409
+
package local:demo;
1410
1410
1411
1411
interface console {
1412
1412
log: func(arg: string);
@@ -1434,7 +1434,7 @@ This is done to implement `use` statements:
1434
1434
1435
1435
```wit
1436
1436
// host.wit
1437
-
package local:demo
1437
+
package local:demo;
1438
1438
1439
1439
interface types {
1440
1440
enum level {
@@ -1479,7 +1479,7 @@ A `world` is represented as a component type.
1479
1479
1480
1480
```wit
1481
1481
// host.wit
1482
-
package local:demo
1482
+
package local:demo;
1483
1483
1484
1484
world the-world {
1485
1485
export test: func();
@@ -1509,7 +1509,7 @@ the parts needed, within the component:
0 commit comments