@@ -104,8 +104,7 @@ keyword ::= 'use'
104
104
| 'string'
105
105
| 'option'
106
106
| 'list'
107
- | 'expected'
108
- | 'unit'
107
+ | 'result'
109
108
| 'as'
110
109
| 'from'
111
110
| 'static'
@@ -349,15 +348,15 @@ sleep: async func(ms: u64)
349
348
Specifically functions have the structure:
350
349
351
350
``` wit
352
- func-item ::= id ':' 'async'? 'func' '(' func-args ') ' func-ret
351
+ func-item ::= id ':' 'async'? 'func' func-tuple '-> ' func-tuple
353
352
354
- func-args ::= func-arg
355
- | func-arg ', ' func-args?
353
+ func-tuple ::= ty
354
+ | '( ' func-named-type-list ')'
356
355
357
- func-arg ::= id ':' ty
356
+ func-named-type-list ::= nil
357
+ | func-named-type ( ',' func-named-type )*
358
358
359
- func-ret ::= nil
360
- | '->' ty
359
+ func-named-type ::= id ':' ty
361
360
```
362
361
363
362
## Item: ` resource `
@@ -405,7 +404,7 @@ such as built-ins. For example:
405
404
406
405
``` wit
407
406
type number = u32
408
- type fallible-function-result = expected <u32, string>
407
+ type fallible-function-result = result <u32, string>
409
408
type headers = list<string>
410
409
```
411
410
@@ -418,11 +417,10 @@ ty ::= 'u8' | 'u16' | 'u32' | 'u64'
418
417
| 'char'
419
418
| 'bool'
420
419
| 'string'
421
- | 'unit'
422
420
| tuple
423
421
| list
424
422
| option
425
- | expected
423
+ | result
426
424
| future
427
425
| stream
428
426
| id
@@ -435,18 +433,25 @@ list ::= 'list' '<' ty '>'
435
433
436
434
option ::= 'option' '<' ty '>'
437
435
438
- expected ::= 'expected' '<' ty ',' ty '>'
436
+ result ::= 'result' '<' ty ',' ty '>'
437
+ | 'result' '<' '_' ',' ty '>'
438
+ | 'result' '<' ty '>'
439
+ | 'result'
439
440
440
441
future ::= 'future' '<' ty '>'
442
+ | 'future'
441
443
442
444
stream ::= 'stream' '<' ty ',' ty '>'
445
+ | 'stream' '<' '_' ',' ty '>'
446
+ | 'stream' '<' ty '>'
447
+ | 'stream'
443
448
```
444
449
445
450
The ` tuple ` type is semantically equivalent to a ` record ` with numerical fields,
446
451
but it frequently can have language-specific meaning so it's provided as a
447
452
first-class type.
448
453
449
- Similarly the ` option ` and ` expected ` types are semantically equivalent to the
454
+ Similarly the ` option ` and ` result ` types are semantically equivalent to the
450
455
variants:
451
456
452
457
``` wit
@@ -455,7 +460,7 @@ variant option {
455
460
some(ty),
456
461
}
457
462
458
- variant expected {
463
+ variant result {
459
464
ok(ok-ty)
460
465
err(err-ty),
461
466
}
0 commit comments