Closed issuesbot closed 11 years ago
[comment from she...@coolpage.com, published at 10/02/2011, 09:12:59]
Ditto Lambda.concat
[comment from ncanna...@gmail.com, published at 10/02/2011, 09:39:14]
[comment from she...@coolpage.com, published at 10/02/2011, 09:51:29] Ditto Lamdba.array, filter, fold, foreach, iter, list, and map. None of these are legal on Iterable, only on a container interface which inherits from Iterable.
Only functions that can terminate before iterator.hasNext() == false are legal on Iterable, e.g. some and every (Lambda doesn't have these).
So the entire Lambda is semantically too broad, because it assume the Iterables are also containers. But Iterable is broader than than a container, it can also include streams that never terminate, i.e. hasNext() always true (or very long time).
[comment from she...@coolpage.com, published at 10/02/2011, 10:15:34] Lambda does have "exists" which is like "some":
[Google Issue #342 : https://code.google.com/p/haxe/issues/detail?id=342] by she...@coolpage.com, at 09/02/2011, 08:21:04 An Iterable is not always countable, because it may not be rewinded or reset on Iterable.iterator(), e.g. a subclass which reads from a stream and does not cache the elements read from the stream.
The semantic of countable belongs in a container, which is a subset of the Iterable category. Iterable means anything that can be enumerated, but that does not imply that everything that can be enumerated must also be collected (i.e. cached or contained).
In short, count should not operate on an Iterable, but rather on a container interface which inherits from Iterable.