types of numeric literals and operators

The draft states (3.1.1) that an integer literal like 1 has
the type xs:integer, not xs:int, even if it is
in the value range of int.

Therefore an expression as simple as 1+1 should be resolved
by the static type checking as an invocation of:

    op:add( x as xs:integer, y as xs:integer ) as xs:integer

Since xs:integer is of arbitrary precision, its
implementation is likely to be heavy, and this would probably
lead to an inefficient implementation.

Moreover, an error should be detected in this apparently
innocent code (because 1 is of type xs:integer):

   define function funny( $x as xs:int ) as xs:int { $x + 1 }

* suggestions:

   1) specify that an integer literal has a minimal type (derived from
      integer) that fits with its value (for example 10 would be int,
      10000000000 would be long)

   2) provide overloaded numeric operators on usual types implemented
      by hardware, in order to have naturally optimized implementations.
      for example:

      op:add( x as xs:int, y as xs:int ) as xs:int
      op:add( x as xs:long, y as xs:long ) as xs:long



-- 
Xavier C. FRANC

Received on Friday, 20 June 2003 16:27:37 UTC