[Issue 4665] map with no automatic closure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 29 18:19:06 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4665


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2010-08-29 18:18:53 PDT ---
It does seem to be a delegate after all. If you try to evaluate it right there
it shows (notice the parantheses after the lambda definition):

import std.algorithm: map;

void main() 
{
    int n = 2;
    map!( (double x){ return x * n; }() )([1.0, 2.0]);
}

Errors:

test.d(10): Error: expected 1 function arguments, not 0
test.d(10): Error: cannot evaluate delegate double(double x)
{
return x * cast(double)n;
}
() at compile time


This seems like a compiler bug. If you use a string instead, then it will work:

import std.algorithm: map;

void main() 
{
    string n = "2";
    map!( (string x){ return x ~ n; } )(["1.0", "2.0"]);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list