Ticket #111 (new defect)
template forEach loop: should not convert collections to arrays, should accept iterators and any kind of object
|Reported by:||bruno||Owned by:||jgou|
The implementation of t:forEach always converts collections to arrays.
I think this is unnecessary, and potentially harmful from a performance point of view (for large collections, or lazy-loaded ones).
Only accepting arrays and collections is also limiting: it would be better to support iterators too, and any other kind of object can be treated as a one-sized collection.
If we would support iterators, this also has implications on the user-visible functionality: the loopStatus variable provides access to 'revIndex' and 'revNumber', which assume the size of the collection is known on beforehand. It doesn't provide access to the size, though I assume this was the intention, since as it is now, it seems you can't know you're in the last loop execution.
CTemplate solves this last point by making available a boolean 'last' property, which doesn't require the size of the collection to be known.