diff --git a/packages/marshal/docs/smallcaps-cheatsheet.md b/packages/marshal/docs/smallcaps-cheatsheet.md index 97e66428ca..a46e2142df 100644 --- a/packages/marshal/docs/smallcaps-cheatsheet.md +++ b/packages/marshal/docs/smallcaps-cheatsheet.md @@ -1,25 +1,26 @@ # Smallcaps Cheatsheet -An example-based summary of the Smallcaps encoding +An example-based summary of the Smallcaps encoding on the OCapN [Abstract Syntax](https://github.com/ocapn/ocapn/blob/28af626441da888c4a520309222e18266dd2f1f2/draft-specifications/Model.md) (as of https://github.com/ocapn/ocapn/pull/125). (TODO revise link once that PR is merged.) -| Passable value | OCapn name | JS example | JSON encoding | -| ----------------|---------------|---------------------|----------------------| -| bigint | Integer | `7n`
`-7n` | `"+7"`
`"-7"` | -| manifest constant | Undefined

Float64


| `undefined`
`Infinity`
`-Infinity`
`NaN`
`-0` | `"#undefined"`
`"#Infinity"`
`"#-Infinity"`
`"#NaN"`
`"#-0"` // unimplemented | -| passable symbol | Symbol | `Symbol.for('foo')`
`Symbol.asyncIterator` | `"%foo"`
`"%@@asyncIterator"` | -| 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
Boolean

Float64 | `null`
`true`
`false`
`7.1` | `null`
`true`
`false`
`7.1` | -| copyArray | List | `[a,b]` | `[,]` | -| copyRecord | Struct | `{x:a,y:b}` | `{:,:}` | -| error | Error | `TypeError(msg)` | `{"#error":,"name":"TypeError"}` | -| tagged | Tagged | `makeTagged(t,p)` | `{"#tag":,"payload":

}` | -| ? | ByteArray | ? | ? | +| pass-style name | OCapn name | JS example | JSON encoding | +| -----------------|---------------|-----------------------|----------------------| +| undefined | Undefined | `undefined` | `"#undefined"` | +| null | Null | `null` | `null` | +| boolean | Boolean | `true`
`false` | `true`
`false` | +| bigint | Integer | `7n`
`-7n` | `"+7"`
`"-7"` | +| number | Float64 | `Infinity`
`-Infinity`
`NaN`
`-0`
`7.1` | `"#Infinity"`
`"#-Infinity"`
`"#NaN"`
`"#-0"` // unimplemented
`7.1` | +| string | String | `'#foo'`
`'foo'` | `"!#foo"` // special strings
`"foo"` // other strings | +| byteArray | ByteArray | `buf.toImmutable()` | // undecided & unimplemented | +| selector | Selector | `makeSelector('foo')` | `"%foo"` // converting from symbol | +| copyArray | List | `[a,b]` | `[
,]` | +| copyRecord | Struct | `{x:a,y:b}` | `{:,:}` | +| tagged | Tagged | `makeTagged(t,p)` | `{"#tag":,"payload":

}` | +| remotable | Target | `Far('foo', {})` | `"$0.foo"` | +| promise | Promise | `Promise.resolve()` | `"&1"` | +| error | Error | `TypeError(msg)` | `{"#error":,"name":"TypeError"}` | * The `-0` encoding is defined as above, but not yet implemented in JS. -* In JS, only registered and well-known symbols are passable. +* In JS, selectors in transition from symbols to their own representation * The number after `"$"` or `"&"` is an index into a separate slots array. * Special strings begin with any of the `!"#$%&'()*+,-` characters. * `` is nested encoding of `expr`. @@ -30,5 +31,3 @@ An example-based summary of the Smallcaps encoding * 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).