Re: Constructing master lists of data types
Alaric Snell-Pym 02 Oct 2019 16:14 UTC
On 01/10/2019 21:05, John Cowan wrote:
> Enums are a
> problem: the native ASN.1 format just sends the ordinal of the enum and
> depends on the ASN.1 schema, which we hates it, so we would need something
> more complex and I don't know what.
With regards to what to send to databases for enums:
MySQL has an enum type, which is written something like
ENUM('FOO','BAR','BAZ'); valid values are then strings 'FOO', 'BAR' or
'BAZ' and I presume the implementation just stores a small enum index on
disk. So a natural mapping of Scheme enums would be to send the symbolic
name as a string by default - DBs without ENUM types can just store a
string, and MySQL with a matching ENUM type in the table will do the
right thing.
Overriding the values sent (using different strings, or just using
numeric indices) should be possible, but just sending the symbol name is
a good default.
As for how to represent them in the serialisation formats - I've not
looked at proposals for R7RS enums yet, but I strongly suspect they'll
need to be sent as the symbolic names as well, even in the binary
format, so that cases where the reader doesn't have the type definition,
or has a different version of the type definition, can still extract
maximal meaning.
--
Alaric Snell-Pym (M7KIT)
http://www.snell-pym.org.uk/alaric/