Skip to content

Commit

Permalink
docs(marshal): Update to latest agreed ocapn terminology (#1988)
Browse files Browse the repository at this point in the history
  • Loading branch information
erights authored Jan 19, 2024
1 parent c295b02 commit bc47a24
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/marshal/docs/smallcaps-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ An example-based summary of the Smallcaps encoding

| Passable value | OCapn name | JS example | JSON encoding |
| ----------------|---------------|---------------------|----------------------|
| bigint | SignedInteger | `7n`<br>`-7n` | `"+7"`<br>`"-7"` |
| bigint | Integer | `7n`<br>`-7n` | `"+7"`<br>`"-7"` |
| manifest constant | Undefined<br><br>Float64<br><br><br> | `undefined`<br>`Infinity`<br>`-Infinity`<br>`NaN`<br>`-0` | `"#undefined"`<br>`"#Infinity"`<br>`"#-Infinity"`<br>`"#NaN"`<br>`"#-0"` // unimplemented |
| passable symbol | Symbol | `Symbol.for('foo')`<br>`Symbol.asyncIterator` | `"%foo"`<br>`"%@@asyncIterator"` |
| remotable | Capability | `Far('foo', {})` | `"$0.foo"` |
| promise | Capability | `Promise.resolve()` | `"&1"` |
| remotable | Remotable | `Far('foo', {})` | `"$0.foo"` |
| promise | Promise | `Promise.resolve()` | `"&1"` |
| special string | String | `'#foo'` | `"!#foo"` |
| other string | String | `'foo'` | `"foo"` |
| other JSON scalar | Null<br>Boolean<br><br>Float64 | `null`<br>`true`<br>`false`<br>`7.1` | `null`<br>`true`<br>`false`<br>`7.1` |
| copyArray | Sequence | `[a,b]` | `[<a>,<b>]` |
| copyArray | List | `[a,b]` | `[<a>,<b>]` |
| copyRecord | Struct | `{x:a,y:b}` | `{<x>:<a>,<y>:<b>}` |
| error | Error | `TypeError(msg)` | `{"#error":<msg>,"name":"TypeError"}` |
| tagged | Tagged | `makeTagged(t,p)` | `{"#tag":<t>,"payload":<p>}` |
| ? | ByteString | ? | ? |
| ? | ByteArray | ? | ? |

* The `-0` encoding is defined as above, but not yet implemented in JS.
* In JS, only registered and well-known symbols are passable.
Expand All @@ -27,6 +27,8 @@ An example-based summary of the Smallcaps encoding
* Structs [can only have string-named properties](https://github.com/endojs/endo/blob/master/packages/pass-style/doc/copyRecord-guarantees.md).
* Errors can also carry an optional `errorId` string property.
* We expect to expand the optional error properties over time.
* The ByteString encoding is not yet designed or implemented.
* The ByteArray encoding is not yet designed or implemented.

Every JSON encoding with no special strings anywhere decodes to itself.

See OCapN [Abstract Syntax](https://github.com/ocapn/ocapn/wiki/Abstract-Syntax).

0 comments on commit bc47a24

Please sign in to comment.