The amazing template which does nothing

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 28 03:18:48 PDT 2015


On Tuesday, 28 April 2015 at 10:18:12 UTC, John Colvin wrote:
> On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana wrote:
>> On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote:
>>> And this has happened to me many times. The solution "Break 
>>> the UFCS chain and use a local temporary variable" makes me 
>>> angry, because by having to do so all the beauty of chaining 
>>> is lost.
>>
>> A very slow (i guess) workaround could be:
>>
>> "test".toUpper.only.map!(a => "This is a " ~ a).front.writeln;
>>
>> vs the new one:
>>
>> "test".toUpper.Identity!(a => "This is a " ~ a).writeln;
>
> Shouldn't be slow, your just giving the optimiser some work to 
> do*, but you're always better off with the second one.
>
> *Assuming a good optimiser. dmd won't work this out.

s/your/you're


More information about the Digitalmars-d mailing list