Steve Yegge's rant on The Next Big Language

janderson askme at me.com
Sun Mar 11 14:43:57 PDT 2007


Johan Granberg wrote:
> 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.

About the optimisation part. I think it would be better to be able to 
specify that a loop's contents are order-independent.

-Joel



More information about the Digitalmars-d-announce mailing list