RE: Question about number types

 
> The three designs available seemed to boil down to:
> 
>    - abstract numeric type with facets to allow definition of
>      floating- and fixed-point numbers with arbitrary bases
>      and capacities -- aka Implementors' Nightmare
>    - abstract numeric type with facets for defining IEEE float
>      and double, which however schema authors are forbidden to
>      use, so the generality of the facet mechanism is purely
>      illusory:  for all intents and purposes, the IEEE types
>      are defined by magic, and the 'facets' are a fig leaf
>    - primitives for the types actually to be supported, with
>      provisions for type coercion in the languages which use
>      them (as, for example, in the XPath Functions and Operators
>      spec)
> 

And perhaps a fourth:

- abstract numeric type having float, decimal, and double as "magic
restrictions", without any attempt to define the restrictions using facets.

I've argued myself for there being a base type for all numerics (and indeed
for "everything with a timezone") on the basis that extra layers in the
hierarchy are useful for defining inheritable operations. The trouble is,
Schema itself doesn't own many operations and therefore doesn't tend to care
very much about this problem: it's mainly concerned with its own operations,
such as lexical->value mapping. But it's conventional in OO systems to allow
the detail of operations to be modified as you go down the type hierarchy;
there's a discipline of good behaviour whereby such modification is supposed
to adhere to a contract, but there is always room for pragmatic compromises
en route to achieve engineering trade-offs. Thus the convenience of being
able to compare numerics of different types is arguably greater than the
inconvenience caused by loss of transitivity in edge cases. I do suspect
that if Schema WG were responsible for defining a wider range of operators
then it might come up with a different type hierarchy.

Michael Kay
http://www.saxonica.com/

Received on Friday, 4 July 2008 16:23:55 UTC