-Union with a single branch
Thiruvalluvan M. G. 2010-12-07, 10:58
The Java implementation allows unions with just one branch. But C++
implementation doesn't. The spec is silent in this respect.
Is there a need for single-branch unions?
There could be an argument that single-branch unions can be used for future
extensions. But I don't think it is needed because our resolution spec
allows matching standalone entities with unions as long as the entity's type
is one of the branches in the union.
Another argument could be that data written using single-branch union can be
read by multi-branch union without using schema resolution. But we do not
want to encourage such usage. If the schemas for reader and writer are
different (in whatever way) we want people to use schema resolution.
The only valid argument I could think of is that someone may already be
using single-branch unions. Tightening the spec will break their code.
Tightening spec will also means that all language implementations should fix
the problem, if they haven't already. In any case we need to make the
implementations consistent and make the specification explicit in this