[Issue 3194] New: invariant should be checked at the beginning and end of protected functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 20 14:12:57 PDT 2009
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 at puremagic.com
ReportedBy: andrei at 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: -------
More information about the Digitalmars-d-bugs
mailing list