home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.eiffel
- Path: sparky!uunet!mcsun!Germany.EU.net!rrz.uni-koeln.de!unidui!math.fu-berlin.de!Sirius.dfn.de!th-ilmenau.RZ.TH-Ilmenau.DE!PrakInf.TH-Ilmenau.DE!huebner
- From: huebner@PrakInf.TH-Ilmenau.DE (Huebner)
- Subject: "Rename" considered hazardous
- Message-ID: <1992Nov23.135527.7035@th-ilmenau.RZ.TH-Ilmenau.DE>
- Sender: news@th-ilmenau.RZ.TH-Ilmenau.DE (Newsserver)
- Nntp-Posting-Host: saturn.prakinf.th-ilmenau.de
- Organization: Technische Hochschule Ilmenau
- Date: Mon, 23 Nov 92 13:55:27 GMT
- Lines: 52
-
-
- Handling the problem of name conflicts arising from multiple inheritance
- by renaming could be a nice solution. But it seems that there should be
- some restrictions to ensure the reliability of the produced software.
-
- By abuse of the renaming mechanism there could the following situation
- become reality:
-
- class A class B
- export f, ... export h, ...
- feature inherit
- f: integer is A rename f as h
- -- "meaning of 'f'" feature
- do ... end; -- no declaration of f
- end end
-
- and anywhere out there is an innocent class C, that believes, that all
- objects of Typ A (or of one of its subtypes) understand the message "f",
- maybe class B is really created after C.
-
- class C
- export foo, ...
- feature
- foo(arg: A): integer is
- -- "meaning of function 'foo'"
- do
- Result := arg.f * 10
- end:
-
- Another innocent (who is innocent?) person wants to use the classes A, B
- and C. SHe only knows and believes in the class interfaces and refuses to
- learn anything about the implementation details of A, B and C.
- So sHe writes:
-
- x: A;
- y: B;
- z: C;
- x.Create; y.Create;
- ...
- z.foo(x); -- o.k.
- z.foo(y); -- Error: message "f" not understood by object of Typ B
-
- Who is the bad boy? - I think it's class B.
- There should be a function f in class B according to the pre-post-conditions
- (and the "meaning" explained) in class A.
- But that forbids the use of rename for cosmetical purposes ("name polishing")
- and requires a more restricted and supervised use of 'rename'.
- I think the example "repeated inheritance and renaming" from ambuj@ucsb.edu
- shows the problems of tricksy programming, enabled by 'rename'.
-
- Michael H"ubner, TU Ilmenau
-
-