foreach thoughts

Timon Gehr timon.gehr at gmx.ch
Tue Jan 14 05:04:57 PST 2014


On 01/14/2014 11:09 AM, Jacob Carlborg wrote:
> On 2014-01-14 09:36, Jakob Ovrum wrote:
>
>> You'll have to get used to the exclamation mark, otherwise you'll never
>> be able to fully appreciate D's generic programming. I quite like it - I
>> don't think there's anything objectively ugly about it.
>
> Or, in this case, fix the compiler to be able to inline delegates. Or is
> there any other advantage of using an alias parameter instead of a
> delegate?
>

1. It is likely to result in faster code when inlining fails. Eg. it 
will often not allocate when the delegate would, due to nested template 
instantiation simplifying escape analysis.

2. IFTI limitations. Eg. the following cannot work with the current 
language unless 'map' is specialized to ranges of int:

[1,2,3].map(x=>2*x)


More information about the Digitalmars-d mailing list