NotNull pointers

Marco Leise Marco.Leise at gmx.de
Wed Aug 31 12:00:31 PDT 2011


Am 31.08.2011, 19:36 Uhr, schrieb Simen Kjaeraas <simen.kjaras at gmail.com>:

> On Wed, 31 Aug 2011 18:57:01 +0200, bearophile  
> <bearophileHUGS at lycos.com> wrote:
>
>> Simen Kjaeraas:
>>
>>> Next iteration:
>>>
>>>      [x; 2 * x; iota(10); x & 1]
>>
>> If you don't like the syntax I've shown with foreach, then use the  
>> Python syntax, it's readable and short and good:
>>
>> [2 * x for x in iota(10) if x & 1]
>> Or:
>> [2 * x for x in 0 .. 10 if x & 1]
>
> I feel it is too much a departure from the style otherwise present in D.  
> It is
> important not only that the syntax is good in and of itself, but also in  
> the
> context of D.

I agree with Simen. Use semicolons where you separate logical parts of the  
expression like in for(each) and commas when you have an argument list or  
enumerations where all elements have the same context or meaning (hard to  
explain). So the Python syntax is [<calculation> for <counter> in <range>  
if <filter>]. I don't know if the filter is actually required, but it  
sounds like a neat idea. How about multidimensional arrays though?


More information about the Digitalmars-d mailing list