opCall/ctor partially sorted out

Jonathan M Davis jmdavisProg at gmx.com
Sat Oct 6 19:45:31 PDT 2012


On Sunday, October 07, 2012 04:24:33 bearophile wrote:
> Recently one of the most important bugs was mostly fixed, beside
> Win64 support this is one of the most important changes in dmd
> 2.061:
> 
> http://d.puremagic.com/issues/show_bug.cgi?id=6036
> 
> 
> Do you think this has to be correct code?
> 
> struct Adder {
>      int v;
>      int opCall(int x) { return x + v; }
> }
> void main() {
>      auto a = Adder(5);
> }

I would argue that that should compile, but it wouldn't surprise me at all if 
it doesn't - especially because of the stupidity that makes it so that you can 
call static functions with member instances, muddying the differences between 
static and non-static in terms of how you call them. And the fact that you 
can't overload a function as static and non-static (probably due to the 
aforementioned nonsense) just makes it worse. So, much as this _should_ work 
IMHO, it doesn't surprise me at all if it doesn't.

- Jonathan M Davis


More information about the Digitalmars-d mailing list