[Issue 6579] New: Calling static method should *require* using type	and not instance
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Tue Aug 30 05:33:45 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=6579
           Summary: Calling static method should *require* using type and
                    not instance
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: schveiguy at yahoo.com
--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-08-30 05:33:42 PDT ---
Consider:
struct S
{
   static int i;
   int x;
   static void reset() {i = i.init;}
}
S instance;
assert(instance.x == 0);
instance.x = 5;
instance.reset();
assert(instance.x == 0); // fails!
This appears to affect instance, but actually it does nothing to the instance,
it only affects the static data.
I think it should require using the type, via:
S.reset();
or
typeof(instance).reset();
This makes it clear that the instance plays no role in the function call.
This also paves the way for bug 3345
I think also this should apply to member fields.  However, enums and aliases
should continue to be accessible using the instance.
-- 
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