On 09/01/2011 12:26 AM, Simen Kjaeraas wrote:
On Wed, 31 Aug 2011 23:54:04 +0200, Timon Gehr <timon.g...@gmx.ch> wrote:

[2 * x ; x <- iota(10), log(x), x*x > 4]

or, in a library:

compr!q {2 * x ; x <- iota(10), log(x), x*x > 4};



compr!q{2 * x ; x <- iota(10), log(x), x*x > 4};

The library solution has problems with scope variables.

I know, that is why I have not implemented this yet. Basically it should be possible to implicitly pass a whole scope to a template, or at least, to have local templates.

Example:

auto foo(Range)(int n, Range r) {
return compr!q{x * n; x <- arr, log(x), x*x > 4};
}

Workaround:
auto foo(Range)(int n, Range r) {
    mixin Compr!q{x * n ; x <- arr, log(x), x*x > 4};
    return compr;
}



More importantly, IMO, is that the notation does not clearly
mark what is what. is that interpreted (iota(10), log(x))
or (log(x), x*x > 4)?


It actually does. The comma is a mere separator, and imho it looks very clean. It is just like the set builder syntax you like. (it even has the curly brackets!)



Reply via email to