- From: Bas de Bakker <bas@x-hive.com>
- Date: Mon, 23 Jun 2003 16:34:40 +0200
- To: <www-ql@w3.org>
I agree. In fact, almost two years ago I submitted a public comment stating: 2. "permits lightweight operations wherever possible". I don't agree. Due to the type of literals and arithmetic operator results, almost all integer values will have type xs:integer and have to be treated internally as "big integers" (unlimited range) as the implementation cannot be sure of their values. Even if the user casts all results to xs:int explicitly, the implementation has to check for overflow on all arithmetic operations. Compiling to code that simply uses machine ints that wrap around on overflow (like Java, most C implementations, etc do) is not possible. I suggest giving literals like [0-9]* type xs:int and defining arithmetic on long, int, short, byte as in Java. This comment was ignored completely. Perhaps someone should submit a comment along these lines as a last-call comment to the F&O draft. The phrase about lightweight operations is still there at the start of section 6. Regards, Bas de Bakker X-Hive Corporation > -----Original Message----- > From: www-ql-request@w3.org [mailto:www-ql-request@w3.org]On Behalf Of > Xavier C. FRANC > Sent: Saturday, June 21, 2003 00:28 > To: www-ql@w3.org > Subject: 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 Monday, 23 June 2003 10:34:47 UTC