Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!mcnc!uvaarpa!murdoch!cds001.cebaf.gov!quarrie From: quarrie@cds001.cebaf.gov (David Quarrie) Newsgroups: comp.lang.eiffel Subject: Re: Three ways to use library-like classes Keywords: library constants Message-ID: <1991May1.132033.29479@murdoch.acc.Virginia.EDU> Date: 1 May 91 13:20:33 GMT References: <1991Apr30.140340.25415@bony1.bony.com> Sender: usenet@murdoch.acc.Virginia.EDU Reply-To: quarrie@cds001.cebaf.gov (David Quarrie) Organization: CEBAF (Continuous Electron Beam Accelerator Facility) Lines: 62 -- In article <1991Apr30.140340.25415@bony1.bony.com>, richieb@bony1.bony.com (Richard Bielak) writes: |>Path: |>murdoch!uvaarpa!haven.umd.edu!udel!wuarchive!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 |> [lines deleted] |> |>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 The method I've used, at least in situations where I want to use a class having lots of constant definitions, is something like the following class COMPLEX is feature mlib: SINGLE_MATH is once Result.Create end; -- mlib end; -- COMPLEX This might look like overkill for the situation where the class contains mainly constants, but it avoids exceeding the limit of 1000 features in an Eiffel class (which amazingly enough I have managed to exceed when using a class containing all the Motif constants), and by using a "once" routine, this attribute is shared by all objects of class COMPLEX, perhaps saving some space relative to Rithie's proposal. It also avoid having to explicitly "Create" the class. It does suffer some additional overhead though, especially when fetching constants from the "included" class. David Quarrie CEBAF (Continuous Electron Beam Accelerator Facility) quarrie@cds001.cebaf.gov