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.
Likewise, it is also possible to annotate records with integers.
A system could use this to reduce the redundancy cost of tags sent
over the wire by indexing tags and substituting them after reading
the structures.
Languages like OCaml use integers instead of symbolic record labels
because their type systems ensure that it is never ambiguous what,
say, the label =23= means in any given context. Allowing integer
record labels lets Preserves directly express OCaml data.
#+BEGIN_SRC preserves
@"The ordered index of tags for this session"
[Employee, Role, Date]
# 2019-08-18 14:06:24 tonyg -- I like the following idea in principle,
# but I don't think it belongs here yet. The *binary* syntax has
# "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..."
#set{<Employee @"employee name"
"Alyssa P. Hacker"
@"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>>}
# A system could use this to reduce the redundancy cost of labels sent
# over the wire by indexing labels and substituting them after reading
# the structures.
@"... 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
# #+BEGIN_SRC preserves
# @"The ordered index of labels for this session"
# [Employee, Role, Date]
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 tags can be anything makes it possible to build this
or any such appropriate structure.
# @"We could then transform this structure..."
# #set{<Employee @"employee name"
# "Alyssa P. Hacker"
# @"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