Correct total ordering and canonicalization
This commit is contained in:
parent
90ed5bc6d7
commit
17368c8961
22
TUTORIAL.org
22
TUTORIAL.org
|
@ -152,15 +152,22 @@ unique elements where ordering of items is unimportant.
|
|||
#set{flour, salt, water}
|
||||
#+END_SRC
|
||||
|
||||
** Total ordering
|
||||
** Total ordering and canonicalization
|
||||
|
||||
This is a good time to mention that even though from a semantic
|
||||
perspective sets and dictionaries do not carry information about the
|
||||
ordering of their elements (and Preserves doesn't care what order we
|
||||
enter them in for our hand-written-as-text Preserves documents), when
|
||||
serializing to binary data (or even when the Preserves library itself
|
||||
serializes to textual data), Preserves will always write out the
|
||||
elements in the same order, every time (aka, "total ordering").
|
||||
enter them in for our hand-written-as-text Preserves documents),
|
||||
Preserves has a well-defined "total ordering".
|
||||
|
||||
*FULL WARNING:* the following claim is not implemented yet. :)
|
||||
Coming soon!
|
||||
|
||||
Based on this total ordering, Preserves provides support for canonical
|
||||
ordering when serializing; in this mode, Preserves will always write
|
||||
out the elements in the same order, every time.
|
||||
When combined with binary serialization, this is Preserves' "canonical
|
||||
form".
|
||||
This is important and useful for many contexts, but especially for
|
||||
cryptographic signatures.
|
||||
|
||||
|
@ -171,13 +178,16 @@ cryptographic signatures.
|
|||
cat: {"noise": "meow",
|
||||
"eats": #set{"kibble", "cat treats", "tinned meat"}}}
|
||||
|
||||
@"Will always, always be written out in this order:"
|
||||
@"Will always, always be written out in this order when canonicalized:"
|
||||
{cat: {"eats": #set{"cat treats", "kibble", "tinned meat"},
|
||||
"noise": "meow"}
|
||||
monkey: {"eats": #set{"bananas", "berries"},
|
||||
"noise": "ooh-ooh"}}
|
||||
#+END_SRC
|
||||
|
||||
This is a bit more expensive than normal serialization (because
|
||||
sorting needs to occur), but is still quite fast in general.
|
||||
|
||||
** Defining our own types using Records
|
||||
|
||||
Finally, there is one more type that Preserves provides... but in a
|
||||
|
|
Loading…
Reference in New Issue