On Mon, 19 Jul 2010 22:42:51 +0200, Philippe Sigaud <philippe.sigaud@gmail.com> wrote:

On Mon, Jul 19, 2010 at 22:06, Simen kjaeraas <simen.kjaras@gmail.com> wrote:
template hasSetter(alias func) if (isCallable!(func)) {
   enum hasSetter = isProperty!(func) &&
       is( typeof( (){ func = ReturnType!(func).init; } ) );
}


In that case, for the second func, the one you call ReturnType on, how does the compiler knows it must take the ref uint one (the getter) and not the void func() one?


Philippe



Simen is using the fact that the compiler already has to figure out if there is an overload that matches the requirements. So it ends up
taking the only one that works. Since it seems to ignore the ref return type property, the property that takes an uint argument must have a
higher precedence (gets checked if it works first).
I wonder if its because Walter probably implemented function overloading before properties and ref return types. Hopefully its a language
feature and not just a implementation side effect.

-Rory