RE: lazy or eager variable initialization? [qt-2004Feb1090-01]

> 
> Permitted, or required?
> 
> Consider something as simple as:
> 
> declare variable $x { $y };
> declare variable $y { 10 };
> $x + $y
> 
> Is this portable, implementation-defined, or neither?
> What about more complex expressions that depend on
> lazy evaluation?

This example doesn't depend on lazy evaluation. It places some demands on
the order of evaluation, but that's not the same thing. Lazy evaluation is
just one strategy for handling this. 

In some functional programming language there is a requirement that lazy
evaluation is used to prevent infinite sequences arising when evaluating
certain expressions. XQuery/XPath imposes no such requirements, it's left to
the implementation, which means that some implementations will fail (run out
of memory or time) with such constructs, when others succeed.

Michael Kay

Received on Wednesday, 23 June 2004 09:05:28 UTC