F&O: casting to/from derived types

Dear WG,

In the new F&O Working Draft (Dec 2001), casting to/from derived types
has been severely restricted.  Too severely.

First, (according to section 14.2) casting from derived types can only
be done to its base type.  This means we can no longer even cast an
integer to a string, a very useful feature, e.g. when creating a string
of text that contains a number:

concat("The result is ", cast as xs:string($x))

I suggest defining casting from a derived type as giving the same result
as casting from its base type to the destination type.  This is easy to
define and understand.  It is also consistent with the idea that you can
use (a value of) a derived type anywhere you can use its base type.

Second, casting TO derived types seems not to be mentioned at all.  Even
though the XQuery WD uses this example in Section 2.3.12:

cast as xs:integer (x div y)

Again, casting to a derived type is easily defined as taking the cast to
its base type and then raising an error if the result is not in the
value space of the derived type.  This would still not allow the example
above without an explicit call to floor/ceiling/round, so you could add
that when converting from decimal to integer or one of its derived
types, truncation is done.

BTW, The text refers to issue 135 of casting to/from derived types and
the introduction even asks for priority feedback on this issue, but I do
not understand the description of the issue in the issues list.

Regards,
Bas de Bakker
X-Hive Corporation

Received on Friday, 11 January 2002 04:59:29 UTC