[Issue 6714] [tdpl] Function literal does not convert to "function" and "delegate" types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 24 04:23:37 PST 2011


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


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au


--- Comment #2 from Don <clugdbug at yahoo.com.au> 2011-12-24 04:23:32 PST ---
(In reply to comment #0)
> Consider:
> 
> 
> void foo (int function (int, int) a){}
> void bar (int delegate (int, int) a){}
> 
> void main ()
> {
>     foo((a, b) { return a +b;});
>     bar((a, b) { return a +b;});
> }
> 
> Neither call works. The literal does not convert to the function or the
> delegate type.

This works though:
     bar((int a, int b) { return a + b;});
Is that what you meant? If it is, then this is a duplicate of 3235.

Or are argument types supposed to be deduced? If so, that's a major,
complicated feature and difficult to implement, I think it requires an extra
level of argument matching. It would need to be considered very carefully.
Eg, which of these calls are ambiguous?

void bar ( double delegate(int, int) a ) {}
void bar ( int delegate (int, int) a ){}

bar( (a, b) { return 1.0; } );
bar( (a, b) { return 1.0f; } );
bar( (a, b) { return a; } );

-- 
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