Merge: Multi iterators
authorJean Privat <jean@pryen.org>
Wed, 7 Oct 2015 17:53:39 +0000 (13:53 -0400)
committerJean Privat <jean@pryen.org>
Wed, 7 Oct 2015 17:53:39 +0000 (13:53 -0400)
Introduce multi-iterators in `for`.

A single `for` can now iterates over more than one collection at once. An iterator is used for each collection and the iteration is finished once the shortest iterator is finished.

~~~nit
for i in [10, 20, 30], j in [1..10] do print i+j # outputs 11 22 33
~~~

As expected by POLA, multi-iterators are also naturally usable on maps and comprehension arrays

~~~nit
var m = new HashMap[Int,String]
m[1] = "one"
m[2] = "two"
for k, v in m, i in [1..10] do print "{k}:{v}:{i}"
# outputs 1:one:1 2:two:2

var a = [for i in [10, 20, 30], j in [1..10] do i + j]
print a # outputs [11, 22, 33]
~~~

Close #1735

Pull-Request: #1748
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

1  2 
src/compiler/abstract_compiler.nit
src/highlight.nit
src/semantize/scope.nit
src/semantize/typing.nit
src/transform.nit

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge