On 10/07/12 04:24, 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); > }
Yes, with resulting a.v==5. This should result in an int == 42: auto a = Adder(37)(5); 'static' either needs to be handled properly or another op needs to be introduced - opStaticCall(). Which might look like a hack, but doing it like that may be simpler to implement and relatively harmless (as the aggregate.op* namespace has to be treated as reserved in practice). Also, the type and instance methods shouldn't form an overload set, so separating them is a good idea (a matching non-static opCall must always take precedence). Calling the static-opCall (either opStaticCall or the "normal" 'static opCall', if/when that one works properly) with an instance should work. (not doing this would need changes to how the null-checking is done and likely cause other problems that i can't think of right now) artur