Thread View: comp.lang.eiffel
1 messages
1 total messages
Started by jos@cs.vu.nl
Mon, 09 Jan 1989 09:24
inheritance and generic parameters
Author: jos@cs.vu.nl
Date: Mon, 09 Jan 1989 09:24
Date: Mon, 09 Jan 1989 09:24
52 lines
1871 bytes
1871 bytes
> Too bad you didn't have access to the actual system; then you could > have seen that solution 1.2b is indeed used in the graphical library > (class GEN_WINDOW). The class actually inherits from > > TREE [like Current] The class variant should include something like w.child = w.child_value. (GEN_WINDOW is a hierarchical window class.) This seems like a waste of memory. The value is always kept twice. Also, it is a kind of redundancy that should be avoided if possible. In this case you need a class TREE without generic parameter. This is a general problem, which can occur for each class with generic parameters. You need the same class with and without generic parameter. You can make a non-generic class from a generic one, using class invariants like the one above, but you can make a generic class from a non-generic one in a conceptually cleaner way. In eiffel the solution could be as follows: Define a class ITREE without generic parameters. This class should look exactly like the existing TREE class. Also define a class GEN_VALUE: class GEN_VALUE[T] export value, change_value feature value : T; change_value(new : T) is do value := new; end; end; Now the generic class TREE can be defined as something like: class TREE[T] export ... -- same as ITREE and node_value, change_node_value. inherit ITREE, GEN_VALUE[T] rename value as node_value, change_value as change_node_value; end; The class GEN_VALUE should be defined only once and can be inherited by each class that needs a generic version. In this way it is easy to support the same class with and without generic parameters. And the redundancy expressed by class variants like w.child = w.child_value is not needed anymore. Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads