[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
Tue Aug 30 09:35:22 PDT 2011


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


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Calling static method       |Calling static method
                   |should *require* using type |should *require* using type
                   |and not instance            |and not instance, unless
                   |                            |specified by author


--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-08-30 09:35:19 PDT ---
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.

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