http://hardy.uhasselt.be/Toga/header.html
I noticed that it has a major flaw with respect to extensibility. So I am proposing a backward incompatible change with respect to the above specification. The change makes the header also more elegant. Please give comments.
Currently the (logical) header consists of fields, some of which are predefined and the remaining ones are free format (they should be regarded as comments). The number of predefined fields is a function of the version number (which is embedded in the header).
Here is the flaw: when the version is upgraded, applications which are not aware of the new version will not know about the added fields and dump them in the free format section.
To give a concrete example. The following header represents a book for normal and suicide chess.
"@PG@\n1.0\n2\nnormal\nsuicide\n(normally comments here)"
Assume v1.1 adds a predefined field xxx. Then the header becomes
"@PG@\n1.1\n2\nnormal\nsuicide\nxxx\n(normally comments here)"
A v1.0 application will interpret xxx as a comment. This may seem harmless but users will not know what xxx means and perhaps delete it. With potentially bad consequences for a v1.1 application which expects the field to be there.
So my suggestion is to put the number of predefined field in the header itself (other than the magic and the version number).
Thus the v1.0 version of the above header will become
"@PG@\n1.0\n3\n2\nnormal\nsuicide\n(normally comments here)"
And the v1.1 version
"@PG@\n1.0\n4\n2\nnormal\nsuicide\nxxx\n(normally comments here)"
A v1.0 application will now simply skip the field xxx which it does not know about.
Here is the Backus Naur form of the proposed changed header. As you can see
logically it is now a tree.
Code: Select all
<header> := <magic>\n<version>\n<root-field>[\n<field>]*
<magic> := @PG@
<version> := <number>.<number>
<root-field> := <number>[\n<multi-field>]*
<multi-field> := [<root-field> | <field>]
<field> := <string>