Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mitel!sce!cognos!jimp From: jimp@cognos.uucp (Jim Patterson) Newsgroups: comp.lang.eiffel Subject: Re: constrained generic problem Keywords: constrained generics, inheritance Message-ID: <5677@cognos.UUCP> Date: 26 Mar 89 05:14:09 GMT References: <9091@alice.UUCP> Reply-To: jimp@cognos.UUCP (Jim Patterson) Organization: Cognos Inc., Ottawa, Canada Lines: 58 In article <9091@alice.UUCP> dbl@alice.UUCP (David Levine, for Kim Bruce) writes: > I have been having problems with constrained generics. >class tree_menu[T -> SIMPLE_NODE] > create is > local new_node : T > do new_node.create; >The problem is that no matter how I instantiate the T, I always get the >operations in SIMPLE_NODE on new_node. The problem is that, in the tree_menu class of your example the class-type which T is instantiated with isn't really known so in fact new_node is always created as a SIMPLE_NODE (as you have described). We have used the following workaround; an instance of the class to which T is bound is created, and passed to any procedures which need to create the complex type. Then, that instance can be used to clone a new instance of that type. In your example, this would be as follows: create(model : T) is local new_node : T; do new_node.clone(model); end; -- in client a : COMPLEX_NODE; t : TREE_MENU[COMPLEX_NODE]; a.create; t.create(a); >P.S. Is anyone else having the problem of getting '5's all over the place >when trying to use the interactive debugger? We had this problem; it seems to be related to a failure by the viewer to recognize timing data in the TERMCAP entries used by Curses. If you remove this information from the TERMCAP entry for your terminal, it should go away. (You may actually need the time delay however, in which case you will have another problem). For example, your vt100 entry likely looks something like this (I've left most of it out): d1|vt100|dec vt100:\ :am:co#80:li#24:cl=50\E[;H\E[2J:bs:cm=5\E[%i%2;%2H:nd=2\E[C:up=2\E[A:\ :ce=3\E[K:cd=50\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m The timing information is any numeric data immediately following an equal sign (=), so with this information stripped the entry will look as follows. d1|vt100|dec vt100:\ :am:co#80:li#24:cl=\E[;H\E[2J:bs:cm=\E[%i%2;%2H:nd=\E[C:up=\E[A:\ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m This problem might be fixed in the next Eiffel release; I really don't know. -- Jim Patterson Cognos Incorporated UUCP:decvax!utzoo!dciem!nrcaer!cognos!jimp P.O. BOX 9707 PHONE:(613)738-1440 3755 Riverside Drive Ottawa, Ont K1G 3Z4