home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!mucs!cs.man.ac.uk!mod
- From: mod@cs.man.ac.uk (Michael O'Docherty (CAG ra))
- Newsgroups: comp.lang.eiffel
- Subject: Type hole in Eiffel
- Message-ID: <mod.712424989@cs.man.ac.uk>
- Date: 29 Jul 92 15:49:49 GMT
- Sender: news@cs.man.ac.uk
- Lines: 85
-
- Please consider the following system of classes, which runs up against
- a type hole in Eiffel 2.3:
-
- ---------------------------------------------
- class CELL[T]
- export
- item, put
- feature
- item:T;
-
- put (v:like item) is
- do
- item := v
- end;
-
- end
- ---------------------------------------------
- class PARENT
- feature
- end
- ---------------------------------------------
- class CHILD
- export
- child_routine
- inherit
- PARENT
- feature
- child_routine is
- do
- end;
- end
- ---------------------------------------------
- class SILLY
- feature
- fill_with_parent(p_cell:CELL[PARENT]) is
- local
- p:PARENT;
- do
- p.Create;
- p_cell.put(p);
- end;
-
- Create is
- local
- c_cell:CELL[CHILD];
- do
- c_cell.Create;
- fill_with_parent(c_cell);
- c_cell.item.child_routine;
- end;
- end
- ---------------------------------------------
-
- The problem stems from the fact that CELL[CHILD] conforms to
- CELL[PARENT]. If you follow through the Create procedure of SILLY
- you'll see that `child_proc' is called on an object whose dynamic type
- is PARENT. This causes 2.3 to seg-fault at run time. I tried a similar
- but more convoluted example of this on EIffel/S for the PC (note that
- this is 3.0) and the error was *caught* at run time and a message
- issued along the lines of ``feature not on object''.
-
- I know this is probably an old and very well known hole, (I believe
- it's the second one outlined in ``A Proposal for Making Eiffel
- Type-Safe'', W.R. Cook, Computer Journal, August 1989). However, there
- are a few questions which I have difficulty finding answers to in the
- FAQ and the Eiffel 3.0 book (either because I'm missing something or
- because they're not there ;^) :
-
- (1) Are all the classes class-valid?
- (2) Is the system system-valid?
- (3) Is this hole caught by ISE Eiffel 3.0 (salivates uncontollably),
- and if so is it caught at compile time or run time?
- (4) Alternatively to (3), have the conformance rules been changed to
- ban this situation?
- (5) Does ISE Eiffel 3.0 enforce every aspect of system and class
- validity (and if so, at run time or compile time)?
- (7) Any other questions I haven't thought of?
- (6) Is that enough questions?
-
-
- Any attempts to answer any or all of these questions greatly appreciated.
-
- Mike.
-
- Internet: mod@cs.man.ac.uk, wet string: (+44) 061 223 1301 ext. 2343
-