Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bony1!richieb From: richieb@bony1.bony.com (Richard Bielak) Newsgroups: comp.lang.eiffel Subject: Three ways to use library-like classes Keywords: library constants Message-ID: <1991Apr30.140340.25415@bony1.bony.com> Date: 30 Apr 91 14:03:40 GMT Reply-To: richieb@bony1.UUCP (Richard Bielak) Organization: Bank of New York Lines: 57 I have seen two different ways of using classes that are "library-like" (I mean classes like SINGLE_MATH, which only contain various math routines, or classes that only define constants). I thought of a third way to use these, that seems (to me anyway) a little cleaner. Here are the three ways, I'll use SINGLE_MATH as an example: 1) Inherit class COMPLEX is inherit SINGLE_MATH feature [...] end; -- COMPLEX I don't like this method, since a COMPLEX number *is not* a SINGLE_MATH library. 2) Attribute class COMPLEX is feature mlib : SINGLE_MATH; [...] end; -- COMPLEX Here any reference to a routine in SINGLE_MATH would be "mlib.something". This is a little better than (1), however "mlib" has to be Created before any calls will work. I don't like having to do the Create. 3) Expanded attribute (my way :-) class COMPLEX is feature mlib: expanded SINGLE_MATH; [...] end; -- COMPLEX Now I can can make calls "mlib.whatever" without having to do a Create on "mlib". It works. What do you think? ...richie -- *-----------------------------------------------------------------------------* | Richie Bielak (212)-815-3072 | Programs are like baby squirrels. Once | | Internet: richieb@bony.com | you pick one up and handle it, you can't | | Bang: uunet!bony1!richieb | put it back. The mother won't feed it. |