Comment 1 for bug 866725

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

Quoting David's email on this:

Unfortunately, this is not a straight forward task because we have a little type mess. For example in src/runtime/collections/collections_impl.cpp:1164, a xs_ulong is subtracted from a ulong and the result passed to a function that accepts ulong. Therefore, a warning is shown on Windows.

We have several situations like this in runtime code. I think, we should forbid to cast away XQuery types in the runtime. Especially if they are passed via XQuery function parameters to the runtime. I think, the only reason why these castings are done is because of the implementation of the store (e.g. the nodes of a collection are saved in a vector ...). Therefore, the castings should be done inside the store and not outside. They are store implementation dependent. Thus, store functions like Collection::nodeAt(...) should expect XQuery types. xs_integer or xs_unsignedLong. And in the long run, the store should throw an error if it detects an overflow. Or maybe, it is able to handle XQuery types some day and does not have to cast them at all. But the decision what to do with the XQuery types should be taken by the store only!

This change would also have consequences to the Zorba API. E.g. Collection::size() returns an unsigned long currently. But the fn:count function of XQuery returns xs:integer. I think, Collection::size() should return xs:integer too. I am not sure if the value should be returned wrapped in an Item or as a value of the type xs_integer. But it should definitely be returned without being casted to different type.