[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
Sat Jun 2 11:06:01 PDT 2012


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


art.08.09 at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |art.08.09 at gmail.com


--- Comment #3 from art.08.09 at gmail.com 2012-06-02 11:07:52 PDT ---
(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.

-- 
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