ceylon/ceylon.language — pull request #435 by lucaswerkmeister (2014-04-21 22:32:30+00:00)
Title: Better Iterable.string for lazy iterables with side effects

The previous implementation would evaluate elements multiple times, which [confused](https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/ceylon-users/0lolW9mxOkg) [people](https://github.com/ceylon/ceylon-compiler/commit/cad85c0b9bd708cda4acefab8437ace2f413adad#commitcomment-5949309) when they printed the iterable (especially that the first element was evaluated once more than the other elements for the emptiness check). This implementation now only evaluates elements exactly as often as necessary (`min { elements.count, 31 }`).

Note: For some weird reason, the js test only succeeds on the second run (`ant test; ant test`). On the first run, the number of iterations is exactly the one that you get with the old implementation, so it seems that it’s still running the old implementation. Does anyone know what might cause this? (cc @chochos, I suppose)

@quintesse wanted to open an issue about this; WDYT?