On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
On Tuesday, 28 April 2015 at 10:18:49 UTC, John Colvin wrote:
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

Trying on d.godbolt.com it seems a lot of extra-code is generated for the first version.

Anyway I think I'm going to rename it "apply". :)

"test".toUpper.apply!(a => "This is a " ~ a).writeln;

It sounds better.

The d.godbolt.org compilers seem a little out of date. I have found problems with their codegen/optimisation that doesn't happen in more recent versions.

ldc 0.15.2 based on llvm 3.5.1 reduces both chains to identical asm.

Reply via email to