Nested Inferred Templates Don't Work?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue May 31 06:51:35 PDT 2011


On 5/31/11 1:04 AM, Mehrdad wrote:
> Hi!
>
> Say I've got a piece of code like this, which gives me the longest line
> in a file:
> pipe!(readText, splitlines, map!((a) { return a.length; }),
> reduce!max)("Demo.txt");
> The problem is, it doesn't work. Which is kind of a bummer. :(
>
> Is there an **elegant** way to get around it?
>
> Of course, I already know I can do this:
> pipe!(readText, splitlines, map!q{ a.length }, reduce!max)("Demo.txt");
> but using strings is very ugly (IMO).
>
> Thanks!

That's a bug in the compiler. You may want to try specifying the 
function literal with types, e.g. function size_t(string a) { return 
a.length; }. A bug report would be appreciated.

Andrei


More information about the Digitalmars-d mailing list