On Wed, 31 Aug 2011 23:16:26 +0200, Timon Gehr <timon.g...@gmx.ch> wrote:
My design is meant to be somewhat similar to for-loops, with the
semicolon-separated expressions, and to set builder notation. I kinda
wish 'in'
was used in foreach loops (foreach(x in foo){}), as that would be a
perfect fit
for the <= in the proposed syntax:
My notation:
[2 * x; x in iota(10); x*x > 4]
Set builder notation:
{2 · x | x ∈ ℕ, x² > 4}
Personally, I find set builder notation to be very clear and
understandable, and
thus worth striving to imitate. In D however, the curly brackets and
comma
operator already have other meanings that we should try not to interfere
with.
The meaning of the comma is already quite overloaded, so, if it is
better readable, I think using comma would be fine.
I'm afraid that's not really an option in this case. It would conflict with
both array literals and the comma operator.
e.g. [2 * x, x in iota(10), x*x > 4] would be seen by the compiler as an
attempt to create an array containing three different types.
also, [2 * x; x in iota(10); log(x), x*x > 4] would be more complex to
write
([2 * x; x in iota(10); (a){ log(a); return a*a > 4;}(x)], possibly?)
--
Simen