NotNull pointers

Timon Gehr timon.gehr at gmx.ch
Wed Aug 31 14:54:04 PDT 2011


On 08/31/2011 11:42 PM, Timon Gehr wrote:
> On 08/31/2011 11:33 PM, Simen Kjaeraas wrote:
>> On Wed, 31 Aug 2011 23:16:26 +0200, Timon Gehr <timon.gehr at 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?)
>>
>>
>
> [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};



More information about the Digitalmars-d mailing list