Path: utzoo!attcan!uunet!mcsun!ukc!pyrltd!tetrauk!rick From: rick@tetrauk.UUCP (Rick Jones) Newsgroups: comp.lang.eiffel Subject: Re: Extension of STRING class Message-ID: <487@tetrauk.UUCP> Date: 8 Jun 90 09:51:44 GMT References: <1990May25.000500.7492@asterix.drev.dnd.ca> <120019@gore.com> <1713@prles2.prl.philips.nl> Reply-To: rick@tetrauk.UUCP (Rick Jones) Organization: Tetra Ltd., Maidenhead, UK Lines: 28 In article <1713@prles2.prl.philips.nl> roosen@cst.philips.nl (Monique Roosen) writes: > >Is there anybody out there in Eiffel-land who knows how to extend >the Eiffel STRING class with a feature for example , > Tail(s:String_ext):String_ext to class STRING_EXT >and still have the possibility for an assignment like > n:STRING_EXT ; > n := "TEST". >I always receive a message like > "STRING is not a descendant class of STRING_EXT". > I think you'll find this comes into the category of "impossible". The assignment A := B is only legal if B is the same class as A, or a descendant of A. The problem with strings is that the Eiffel compiler has the class STRING built in to its idea of a string literal, and you can't change that. "TEST" is always treated as a STRING type, so your assignment is not legal. If you really want to do this, it seems one case where you have to go into the kernel library and add your feature directly to string.e. Anyone know any smarter solutions? -- Rick Jones You gotta stand for something Tetra Ltd. Maidenhead, Berks Or you'll fall for anything rick@tetrauk.uucp (...!ukc!tetrauk.uucp!rick) - John Cougar Mellencamp