Overloading static methods

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Aug 30 08:38:54 PDT 2011


On 8/30/11 7:34 AM, Steven Schveighoffer wrote:
> On Tue, 30 Aug 2011 07:53:15 -0400, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
>
>> On Mon, 29 Aug 2011 10:59:22 -0400, Daniel Murphy
>> <yebblies at nospamgmail.com> wrote:
>>
>>> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
>>> news:op.v0zckubyeav7ka at localhost.localdomain...
>>>>
>>>> My opinion is that static methods should *not* be callable from an
>>>> instance, you should need typeof(instance).staticMethod. The current
>>>> allowance is misleading.
>>>>
>>>> This should solve some of the issues, but of course, you'd need to
>>>> allow
>>>> overloading of the method name in static and non-static forms.
>>>>
>>>> -Steve
>>>
>>> I like this idea. Is there a bugzilla entry for it?
>>
>> I'll add it, if it's not already there.
>
> http://d.puremagic.com/issues/show_bug.cgi?id=6579
>
> -Steve

I'll note that calls of static methods for instances has been a boon to 
generic programming in C++. People could call a method and it was up to 
the implementation whether it was static or not.

We don't have as big a problem in D due to introspection. I fear, 
however, that we'll need to add static if (...) obj.method(); else 
typeof(obj).method();

I don't see an improvement.


Andrei


More information about the Digitalmars-d mailing list