Comment out example of integer record labels, and explain why I'm uneasy about it

This commit is contained in:
Tony Garnock-Jones 2019-08-18 14:24:02 +01:00
parent 2db315d140
commit e38f56c1c3
1 changed files with 56 additions and 39 deletions

View File

@ -293,49 +293,66 @@ Preserves can also be used to coordinate meaning in larger, more
decentralized systems. decentralized systems.
Likewise, it is also possible to annotate records with integers. Likewise, it is also possible to annotate records with integers.
A system could use this to reduce the redundancy cost of tags sent Languages like OCaml use integers instead of symbolic record labels
over the wire by indexing tags and substituting them after reading because their type systems ensure that it is never ambiguous what,
the structures. say, the label =23= means in any given context. Allowing integer
record labels lets Preserves directly express OCaml data.
#+BEGIN_SRC preserves # 2019-08-18 14:06:24 tonyg -- I like the following idea in principle,
@"The ordered index of tags for this session" # but I don't think it belongs here yet. The *binary* syntax has
[Employee, Role, Date] # "placeholder" values but the *text* syntax doesn't. Preserves is all
# about equivalences: so <1 #true> is different from <Employee #true>.
# If you don't have the key -- the mapping between 1 and Employee --
# you can't know to identify the two! It's an open design question
# whether to keep placeholder values, and if so how to introduce them
# (!) without causing confusion; it's probably better in general to
# just gzip encoded values (!!)...
#
# -- original text from dustyweb follows --
@"We could then transform this structure..." # A system could use this to reduce the redundancy cost of labels sent
#set{<Employee @"employee name" # over the wire by indexing labels and substituting them after reading
"Alyssa P. Hacker" # the structures.
@"employee roles"
#set{<Role Programmer>,
<Role Manager>},
@"when hired"
<Date 2018, 1, 24>>,
<Employee @"employee name"
"Ben Bitdiddle"
@"employee roles"
#set{<Role Programmer>},
@"when hired"
<Date 2019, 2, 13>>}
@"... to this structure, which in binary is 91 as opposed to 127 bytes" # #+BEGIN_SRC preserves
#set{<0 @"employee name" # @"The ordered index of labels for this session"
"Alyssa P. Hacker" # [Employee, Role, Date]
@"employee roles"
#set{<1 Programmer>,
<1 Manager>},
@"when hired"
<2 2018, 1, 24>>,
<0 @"employee name"
"Ben Bitdiddle"
@"employee roles"
#set{<1 Programmer>},
@"when hired"
<2 2019, 2, 13>>}
#+END_SRC
Even in this trivial example, this is a 25% reduction in the binary size. # @"We could then transform this structure..."
Even though tooling to do this does not come out of the box in Preserves, # #set{<Employee @"employee name"
the fact that Record tags can be anything makes it possible to build this # "Alyssa P. Hacker"
or any such appropriate structure. # @"employee roles"
# #set{<Role Programmer>,
# <Role Manager>},
# @"when hired"
# <Date 2018, 1, 24>>,
# <Employee @"employee name"
# "Ben Bitdiddle"
# @"employee roles"
# #set{<Role Programmer>},
# @"when hired"
# <Date 2019, 2, 13>>}
# @"... to this structure, which in binary is 91 as opposed to 127 bytes"
# #set{<0 @"employee name"
# "Alyssa P. Hacker"
# @"employee roles"
# #set{<1 Programmer>,
# <1 Manager>},
# @"when hired"
# <2 2018, 1, 24>>,
# <0 @"employee name"
# "Ben Bitdiddle"
# @"employee roles"
# #set{<1 Programmer>},
# @"when hired"
# <2 2019, 2, 13>>}
# #+END_SRC
# Even in this trivial example, this is a 25% reduction in the binary size.
# Even though tooling to do this does not come out of the box in Preserves,
# the fact that Record labels can be anything makes it possible to build this
# or any such appropriate structure.
** Annotations ** Annotations