Path: news.daimi.aau.dk!olevi From: olevi@daimi.aau.dk (Ole Villumsen) Newsgroups: comp.lang.beta Subject: Re: Protected in BETA ? Date: 21 Nov 1995 14:50:13 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 44 Message-ID: <48sov5$80j@krone.daimi.aau.dk> References: NNTP-Posting-Host: austin.daimi.aau.dk Last week, Eydun Eli Jacobsen asked: >Is there a way in BETA to model the protected feature of C++ ? ... >A: (# > Representation:< (# ... #); > priv: @Representation; > #); >B: A(# > Representation::< (# ... #); > #); >This "information hiding" is not enforced by the compiler, but relies >on programmers discipline. :-) Since you start out from C++, it may be worth noting that Bjarne Stroustrup claims that all information hiding in programming relies ultimately on programmer discipline. The clever programmer who need a hack to circumvent the information hiding (well, we can discuss how clever s/he is :-), will invent such a hack. In Beta, I usually use something like: A: (# priv: @<>; #); B: A(# morePriv: @<>; #); If the implementation part of B needs access to the private ("protected") data in A, it can include the body fragment containing the definition of the Apriv slot. (Note that this needs not be the same fragment as the one containing the entire A implementation.) (If priv in A is private in the C++ sense, the "INCLUDE" is omitted.) I agree with you, no really ideal solution exists. Hope the above helps anyway. Ole V. In no place, market's powers and economic growth have abolished poverty. (Simon Stocker, lobbyist for Eurostep)