Path: news.daimi.aau.dk!poe From: Jacob Seligmann Newsgroups: comp.lang.beta Subject: Re: Two question on assignement Date: 14 Jun 1995 15:44:16 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 26 Approved: mailtonews@daimi.aau.dk Distribution: world Message-ID: <3rn04g$5ia@belfort.daimi.aau.dk> NNTP-Posting-Host: daimi.daimi.aau.dk Dario Gerosa wrote: > I'm implementing a Dictionary pattern with heterogeneous > keys and values (association). To return a value I need > to assign a less qualified object (ref-to-Object) to > a more qualified object (es. ref-to-Text). In theory > this is wrong. Does it exist a legal BETA method to do > that assignment ? Reverse assignments (assignments from less specific to more specific object references) can often be avoided by restructuring your code, but are sometimes very useful, e.g. when manipulating heterogeneous collections. They are not considered "wrong". Unlike C(++)'s cast operations, reverse assignments in BETA trigger run-time qualification checks to ensure that the operation is legal. If memory serves me right, the basic BETA environment has a "qua"-pattern to facilitate object-to- subclass-object casting; check out betaenv.bet for details. Also see FAQ Question C03. /Jacob Seligmann ------------------------------------------------------------------------ Systematic Software Engineering A/S Phone: 86 15 18 66 Frichsparken Direct: 86 15 18 22 - 116 Soeren Frichs Vej 42 K Fax: 86 15 19 66 DK-8230 Aabyhoej, Denmark E-mail: jas@systematic.dk ------------------------------------------------------------------------