Up to Main Index                         Up to Journal for September, 2018

                  JOURNAL FOR SATURDAY 29TH SEPTEMBER, 2018
______________________________________________________________________________

SUBJECT: More recordjar updates
   DATE: Sat 29 Sep 17:14:51 BST 2018

Public dev branch has just been updated with another batch of updates for the
recordjar package. The changes include some tidying up and a few bug fixes.

In the tidying up category the KeyedString has been dropped from the encoder
and decoder. The KeyedString was pretty pointless. I can’t think of a single
use case for it, you always want to use a KeyedStringList instead. As a
reminder a KeyedString looks like:


  Veto: GET→You can't get that!


In this case we are defining a veto. Defining a single KeyedString is just a
specific case of a KeyedStringList with only one item. The only advantage of a
KeyedString was that you could only specify zero or one keyed string, with a
KeyedStringList you can specify zero or more, for example we can define
multiple vetoes:


  Vetoes: GET→You can't get that!
        : PUT→You can't put it anywhere.


Originally KeyedString was added because it filled a perceived gap in the
encoder and decoder API. It also made implementing a KeyedStringList simple,
it was just a list of KeyedStrings. Neither of these seem to be strong enough
justifications for inclusion in the API. Therefore, KeyedString is no more.

In the fixes category I sorted out what I wanted to do with nameless values.
My indecision was obvious from this test case for the PairList:


  {map[string]string{"": "z"}, '→', "→z"}, // correct?


It wasn’t obvious at the time if the result should have been "→z", that is the
empty string is a valid name, or if the result should have been "". In the end
I decided that if the name evaluated to an empty string then we had no name to
store the value under, so nameless values are now ignored.

This change has been implemented for encoding/decoding a PairList and for
encoding a KeyedStringList. Decoding a KeyedStringList already ignored
nameless values.

A minor nit in encoding a PairList has been fixed. If a value contained white
space only it was still written out, resulting in the delimiter being written
even though unnecessary. For example ‘Vetoes: GET→’ should be ‘Vetoes: GET’,
although this example makes no sense as a message should be specified.

Currently I’m working on tests for encoding and decoding together. For example
if something is decoded, then encoding it and decoding it should give the same
results. Similarly encoding something, then decoding it and encoding it again
should give the same results.

In other news, the SD card in my original Raspberry Pi died again. It seems
that once an SD card starts to develop bad blocks it will only develop more of
them over time. I’ve not had the time to try recovering the SD card again to
see what happens next.

--
Diddymus


  Up to Main Index                         Up to Journal for September, 2018