Skip to content

Commit 753207a

Browse files
committed
Add 'error' type and 'canon error.{new,debug-message,drop}' built-ins
1 parent ec2763b commit 753207a

File tree

6 files changed

+372
-99
lines changed

6 files changed

+372
-99
lines changed

design/mvp/Async.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,10 @@ f: func(x: whatever) -> stream<T>;
232232
g: func(s: stream<T>) -> stuff;
233233
```
234234
`g(f(x))` works as you might hope, concurrently streaming `x` into `f` which
235-
concurrently streams its results into `g`. (The addition of [`error`](#TODO)
236-
will provide a generic answer to the question of what happens if `f`
237-
experiences an error: `f` can close its returned writable stream end with an
238-
`error` that will be propagated into `g` which should then propagate the error
239-
somehow into `stuff`.)
235+
concurrently streams its results into `g`. If `f` has an error, it can close
236+
its returned `stream<T>` with an [`error`](Explainer.md#error-type) value
237+
which `g` will receive along with the notification that its readable stream
238+
was closed.
240239

241240
If a component instance *would* receive the readable end of a stream for which
242241
it already owns the writable end, the readable end disappears and the existing
@@ -518,7 +517,6 @@ For now, this remains a [TODO](#todo) and validation will reject `async`-lifted
518517
Native async support is being proposed incrementally. The following features
519518
will be added in future chunks roughly in the order list to complete the full
520519
"async" story:
521-
* add `error` type that can be included when closing a stream/future
522520
* `nonblocking` function type attribute: allow a function to declare in its
523521
type that it will not transitively do anything blocking
524522
* define what `async` means for `start` functions (top-level await + background

design/mvp/Binary.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ primvaltype ::= 0x7f => bool
190190
| 0x75 => f64
191191
| 0x74 => char
192192
| 0x73 => string
193+
| 0x64 => error
193194
defvaltype ::= pvt:<primvaltype> => pvt
194195
| 0x72 lt*:vec(<labelvaltype>) => (record (field lt)*) (if |lt*| > 0)
195196
| 0x71 case*:vec(<case>) => (variant case+) (if |case*| > 0)
@@ -307,6 +308,9 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
307308
| 0x19 async?:<async?> => (canon future.cancel-write async? (core func)) 🔀
308309
| 0x1a t:<typeidx> => (canon future.close-readable t (core func)) 🔀
309310
| 0x1b t:<typeidx> => (canon future.close-writable t (core func)) 🔀
311+
| 0x1c opts:<opts> => (canon error.new opts (core func)) 🔀
312+
| 0x1d opts:<opts> => (canon error.debug-message opts (core func)) 🔀
313+
| 0x1e => (canon error.drop (core func)) 🔀
310314
async? ::= 0x00 =>
311315
| 0x01 => async
312316
opts ::= opt*:vec(<canonopt>) => opt*
@@ -478,6 +482,7 @@ named once.
478482

479483
## Binary Format Warts to Fix in a 1.0 Release
480484

485+
* The opcodes (for types, canon built-ins, etc) should be re-sorted
481486
* The two `list` type codes should be merged into one with an optional immediate.
482487
* The `0x00` prefix byte of `importname'` and `exportname'` will be removed or repurposed.
483488

0 commit comments

Comments
 (0)