[Issue 8098] Inner class method can modify outer's members regardless of constancy

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 15 07:46:20 PDT 2012


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



--- Comment #1 from Stewart Gordon <smjg at iname.com> 2012-05-15 07:47:50 PDT ---
An inner class holds a hidden member that is a reference to the object of the
outer class to which it belongs.  By transitivity, if inner is const or
immutable, then outer must be likewise from inner's point of view.

This implies that an immutable inner can only belong to an immutable outer, and
a const inner can belong to a mutable, const or immutable outer, but inner will
always view the outer as const.

At the moment there doesn't seem to be a way to explicitly set the constancy of
Inner.outer.  But if there were, it would enable a mutable inner to belong to
an outer of any constancy while ensuring const-safety (though the outer class
might not be able to hold a reference to the inner object).

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