diff --git a/syndicate/mc/preserve.md b/syndicate/mc/preserve.md index 97892f4..7ef79c1 100644 --- a/syndicate/mc/preserve.md +++ b/syndicate/mc/preserve.md @@ -548,25 +548,25 @@ For the following examples, imagine an application that maps `Record` short form label number 0 to label `discard`, 1 to `capture`, and 2 to `observe`. -| Value | Encoded hexadecimal byte sequence | -|--------------------------------------------------------------------|----------------------------------------------------| -| `(capture (discard))` | 91 80 | -| `(observe (speak (discard) (capture (discard))))` | A1 B3 75 73 70 65 61 6B 80 91 80 | -| `[1 2 3 4]` (format B) | C4 11 12 13 14 | -| `[1 2 3 4]` (format C) | 2C 11 12 13 14 3C | -| `[-2 -1 0 1]` | C4 1E 1F 10 11 | -| `"hello"` (format B) | 55 68 65 6C 6C 6F | -| `"hello"` (format C, 2 chunks) | 25 62 68 65 63 6C 6C 6F 35 | -| `"hello"` (format C, 5 chunks) | 25 62 68 65 62 6C 6C 60 60 61 6F 35 | -| `["hello" there #"world" [] #set{} #t #f]` | C7 55 68 65 6C 6C 6F 75 74 68 65 72 65 C0 D0 01 00 | -| `-257` | 42 FE FF | -| `-1` | 1F | -| `0` | 10 | -| `1` | 11 | -| `255` | 42 00 FF | -| `1f` | 02 3F 80 00 00 | -| `1d` | 03 3F F0 00 00 00 00 00 00 | -| `-1.202e300d` | 03 FE 3C B7 B7 59 BF 04 26 | +| Value | Encoded hexadecimal byte sequence | +|---------------------------------------------------|----------------------------------------------------------------------| +| `(capture (discard))` | 91 80 | +| `(observe (speak (discard) (capture (discard))))` | A1 B3 75 73 70 65 61 6B 80 91 80 | +| `[1 2 3 4]` (format B) | C4 11 12 13 14 | +| `[1 2 3 4]` (format C) | 2C 11 12 13 14 3C | +| `[-2 -1 0 1]` | C4 1E 1F 10 11 | +| `"hello"` (format B) | 55 68 65 6C 6C 6F | +| `"hello"` (format C, 2 chunks) | 25 62 68 65 63 6C 6C 6F 35 | +| `"hello"` (format C, 5 chunks) | 25 62 68 65 62 6C 6C 60 60 61 6F 35 | +| `["hello" there #"world" [] #set{} #t #f]` | C7 55 68 65 6C 6C 6F 75 74 68 65 72 65 65 77 6F 72 6C 64 C0 D0 01 00 | +| `-257` | 42 FE FF | +| `-1` | 1F | +| `0` | 10 | +| `1` | 11 | +| `255` | 42 00 FF | +| `1f` | 02 3F 80 00 00 | +| `1d` | 03 3F F0 00 00 00 00 00 00 | +| `-1.202e300d` | 03 FE 3C B7 B7 59 BF 04 26 | Finally, a larger example, using a non-`Symbol` label for a record.[^extensibility2] The `Record` @@ -902,9 +902,9 @@ or `Record`s. - `ByteString` ↔ `bytes` - `Symbol` ↔ a simple data class wrapping a `unicode` - `Record` ↔ something like `namedtuple`, but that doesn't care about class identity? - - `Sequence` ↔ `list` - - `Set` ↔ `set` - - `Dictionary` ↔ `dict` + - `Sequence` ↔ `tuple` (but accept `list` during encoding) + - `Set` ↔ `frozenset` (but accept `set` during encoding) + - `Dictionary` ↔ a hashable (immutable) dictionary-like thing (but accept `dict` during encoding) ### Squeak Smalltalk @@ -1082,4 +1082,13 @@ Q. Literal small integers: are they pulling their weight? They're not absolutely necessary. They mess up the connection between value-ordering and repr-ordering! +Q. Should we go for trying to make the data ordering line up with the +encoding ordering? We'd have to only use streaming forms, and avoid +the small integer encoding, and not store record arities, and sort +sets and dictionaries, and mask floats and doubles (perhaps +[like this](https://stackoverflow.com/questions/43299299/sorting-floating-point-values-using-their-byte-representation)), +and I don't know what to do about SignedIntegers. Perhaps make them +more like float formats, with the byte count acting as a kind of +exponent underneath the sign bit. + ## Notes