Steve Yegge's rant on The Next Big Language

Johan Granberg lijat.meREM at OVE.gmail.com
Sun Mar 11 12:28:17 PDT 2007


janderson wrote:

> Jarrett Billingsley wrote:
>> 
>> Basically it's a way of really easily applying functions and such over a
>> list.  They're kind of like array operations (a[] = b[] + c[]), which D
>> doesn't have yet, but more flexible.  You can do stuff like (using very
>> python-like syntax):
>> 
>> int[] numbers = [1, 2, 3, 4, 5, 6, 7, 8];
>> 
>> // This loops through numbers, seeing if the condition holds true,
>> // and if it does, adds it to a new list, which is eventually assigned
>> // to evens.
>> int[] evens = [x for x in numbers if !(x & 1)];
>> 
>> // Square the list
>> int[] squares = [x * x for x in numbers];
> 
> I'm not sure about these.  The syntax is not much better then a foreach
> loop.

But they are expressions instead of statements which can be important in
some situations, and they are probably more limited (no defined ordering)
something that could be used in optimizations.



More information about the Digitalmars-d-announce mailing list