From: Kent Dahl Date: 2003-06-25T22:00:22+09:00 Subject: Re: protect parents from children Simon Strandgaard wrote: > > On Wed, 25 Jun 2003 13:29:31 +0000, Martin DeMello wrote: > > > Simon Strandgaard <0bz63fz3m1qt3001@sneakemail.com> wrote: > >> In C++ private members is inacessable to derivatived classes. > >> I want the same, but with a extra twist. > >> Instances declared in the parent should be readonly(frozen) to the > >> subclass. > >> > >> So that the subclass (B): > >> * is allowed to read the variable. > >> * is disallowed to write to the variable (raise exception). > > > > Offhand, I'd say it wasn't even hackable in pure ruby, because > > [snip] > > I am sad to hear that. Then I have to learn to live without protection. > Thanks Guy+Martin for the discussion it has been educational. > > BTW: Perhaps it could be nice if you could say: > > class A > def initialize > @value = [1, 2, 3] > end > subclass_freeze :value # maybe nice to have ? > end > > -- > Simon Strandgaard -- (\[ Kent Dahl ]/)_ _~_ _____[ http://www.pvv.org/~kentda/ ]_____/~ ))\_student_/(( \__d L b__/ (pre-) Master of Science in Technology ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)