On 1/21/2013 10:57 AM, David Lee wrote:

--

Because "treat as" is an assertion designed so the query author can tell a pessimistic static type checker to get out of the way and mind its own business, it is needed only in systems that do pessimistic static type checking, which are very few and far between. (Galax and SQL Server are the only ones that come to mind).

Michael Kay
Saxonica

----

Do you know of any cases where "treat as" is necessary in XQuery ?

Or is it the equivalent of a static assert that otherwise would cause a dynamic error ?


David - I've run across them in a somewhat obscure context, I guess. I've written an XQuery processor that rewrites queries originally parsed by Saxon, basically serializing them in the process. All I can tell you is that Saxon generates an internal expression (ItemChecker) that is documented as corresponding to "treat as" in some cases where there was no "treat as" in the original supplied expression.

I think this happens, eg, if you declare a variable with a certain type (so the type will be checked dynamically when the assignment is done), but later references to the variable's value can be wrapped in a "treat as" so that the compiler can assume that the variable has the declared type and perform suitable automatic type inferencing. But that's just a guess :)

-Mike
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to