Hi! > I think my main point of feedback would be to stick closer to existing PHP > syntax, even if it costs us some brevity. I would prefer > > $gen = [foreach ($list as $x) if ($x % 2) yield $x * 2]; > > over > > $gen = [for $list as $x if $x % 2 yield $x * 2];
Agree here. There's a principle of least surprise - "for" in PHP looks the certain way, and sequence iteration looks certain way, and it's better to work within those paradigms than import different way of doing the same from Python. Especially given that for/foreach look pretty close, and remembering in which context "for" is ok for sequences and in which not is going to be very annoying. It's much easier to remember "for is always for(x;y;z), foreach is always foreach(x as y=>z)". Also agree about parentheses - reading a complex expression without separators would be annoying. I know python loves to do this but even in an IDE with highlighter it's not always easy to quickly figure out which part belongs where. Delimiting it would make it easier IMHO, and also allows again to carry over the intuition of how foreach() and if() work from already known constructs. > Finally, Python makes a distinction between list comprehensions using [] > and generator expressions using (). This proposal effectively corresponds > to generator expressions, but uses the [] syntax. I'm wondering if that > will cause confusion. Do we need this distinction for anything useful? -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php