www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3194] New: invariant should be checked at the beginning and end of protected functions

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

           Summary: invariant should be checked at the beginning and end
                    of protected functions
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrei metalanguage.com


Consider:

class A
{
    invariant() { ... }
    public void f() { ... }
    protected void g() { ... }
}

Currently invariant is called at the beginning and end of each public function,
the end of the constructor, and the beginning of the destructor. Scott Meyers
pointed out to a quite known fact - protected is much closer to public than to
private in terms of offering access control. This is because anyone can just
inherit from a class and call protected methods, or even wrap them in public
methods.

Consequently, it looks like the invariant of a class must also hold upon entry
and exit of all protected methods.

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