Ihe Onwuka

2014-03-14 13:59:12 UTC

does (expr1, expr2,.......,exprN)[1] and variants thereof evaluate

lazily. Is this implementation dependent.

lazily. Is this implementation dependent.

Discussion:

(too old to reply)

Ihe Onwuka

2014-03-14 13:59:12 UTC

does (expr1, expr2,.......,exprN)[1] and variants thereof evaluate

lazily. Is this implementation dependent.

lazily. Is this implementation dependent.

Ihe Onwuka

2014-03-14 14:32:33 UTC

Well (4,5 div 0)[1] on Saxon gives 4. Hurray.

(4,5 div 0)[1] in eXist gives divide by zero error. Boo.

So the answer seems to be it depends.

*Post by Ihe Onwuka*

does (expr1, expr2,.......,exprN)[1] and variants thereof evaluate

lazily. Is this implementation dependent.

(4,5 div 0)[1] in eXist gives divide by zero error. Boo.

So the answer seems to be it depends.

does (expr1, expr2,.......,exprN)[1] and variants thereof evaluate

lazily. Is this implementation dependent.

Michael Kay

2014-03-14 16:12:48 UTC

Well (4,5 div 0)[1] on Saxon gives 4. Hurray.

(4,5 div 0)[1] in eXist gives divide by zero error. Boo.

So the answer seems to be it depends.

Saxon would fail on (4, 5 div 0, 6)[3], but other products might return 6.

The rule (see the "Errors and Optimization" section of the spec) is (my precis) that a processor doesn't have to evaluate an expression if it doesn't need to know the value of that expression in order to deliver the final result, and in particular, it never needs to evaluate an expression merely in order to discover whether evaluating it throws an error.

Michael Kay

Saxonica

Continue reading on *narkive*:

Search results for *'lazy evaluation of sequences'* (newsgroups and mailing lists)

57

replies
Running out of memory when using filter?

started 2008-12-05 05:20:37 UTC

clojure@googlegroups.com

8

replies
Observations about new lazy branch

started 2009-02-28 10:10:38 UTC

clojure@googlegroups.com

5

replies
Concatenating many lists (stack overflow problem)

started 2009-03-02 06:53:08 UTC

clojure@googlegroups.com

32

replies
[newbie] strange behaviour in self-referential primes lazy-seq attempt

started 2015-02-13 00:50:02 UTC

clojure@googlegroups.com

11

replies
motivation behind laziness of apply in ClojureScript

started 2012-03-28 11:51:39 UTC

clojure@googlegroups.com

Loading...