alias to function literal, call without () not possible

Andre Pany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 3 12:40:46 PDT 2016


On Wednesday, 3 August 2016 at 18:15:23 UTC, Anonymouse wrote:
> On Wednesday, 3 August 2016 at 17:16:10 UTC, Andre Pany wrote:
>> [...]
>
>> [...]
> ...is an alias for a delegate/function returning an Object. It 
> is analogous to
>> [...]
>
>> [...]
> ...is a function accepting an Object parameter. In main you are 
> trying to call this overload
>> [...]
> ...which is essentially
>> [...]
>
> You can use pragma(msg, typeof(symbol).stringof) to inspect 
> what types are being thrown around.
>> [...]
>
> You could argue that parameterless function call rules should 
> apply here and have it implicitly converted to bar(foo()), but 
> it doesn't. I imagine the ambiguity (of delegate vs function 
> return value) would just cause more problems than it would 
> solve.

Thanks for the info. Yes, I forgot the () for new Object;
Adding the () for new Object() still returns the same error.
I think you are right with the ambiguity.

Kind regards
André


More information about the Digitalmars-d-learn mailing list