[Issue 6579] Calling static method should *require* using type and not instance, unless specified by author

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 3 05:26:27 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6579


Gor Gyolchanyan <gor at boloneum.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gor at boloneum.com


--- Comment #4 from Gor Gyolchanyan <gor at boloneum.com> 2012-06-03 05:28:22 PDT ---
(In reply to comment #3)
> (In reply to comment #2)
> > Revised proposal:
> > 
> > One cannot call a static method using an instance method unless the author
> > aliases it into the instance namespace.
> > 
> > Andrei pointed out that one can design a static method *intending* it to be
> > used on an instance, for example to save a virtual method call when it's not
> > needed, but still implement a generic interface.
> > 
> > For the cases where a static method was intended to be callable from an
> > instance, there should be a provision for that.
> > 
> > A sample proposal:
> > 
> > struct S
> > {
> >    static void foo() {}
> >    alias foo this.foo;
> > }
> > 
> > Now an instance of S can be used to call foo.
> 
> a) I don't see any real need to separate type and instance methods
> b) OTOH i don't think it can do much harm either. But overloading alias further
> does not seem like the best idea. 'static @method void foo() {}' - @method is
> needed for UFCS too, where it would do something similar.

It hinders overloading. For so long I wanted to be able to have both static and
non-static opDispatch and opCall and couldn't because of this. This behavior is
not doing any good anyway.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list