From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,842accb6a7d76669 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-11 13:27:02 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!dispose.news.demon.net!news.demon.co.uk!demon!pogner.demon.co.uk!zap!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: List container strawman 1.1 Date: 11 Nov 2001 21:09:04 +0000 Organization: Pushface Message-ID: References: <3BE301D1.4010106@telepath.com> <3BE7DA00.8020807@acm.org> <9sdojl$e6h$1@news.huji.ac.il> <3BEACA5A.9030100@acm.org> <20TG7.18929$xS6.30469@www.newsranger.com> <9sh49o$ohc$1@nh.pace.co.uk> <3BEC9207.5070309@telepath.com> <3BECA6F9.B317CB11@acm.org> NNTP-Posting-Host: localhost X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 X-Trace: news.demon.co.uk 1005514003 nnrp-12:27444 NO-IDENT pogner.demon.co.uk:158.152.70.98 X-Complaints-To: abuse@demon.net NNTP-Posting-Date: 11 Nov 2001 21:09:04 GMT X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:16300 Date: 2001-11-11T21:09:04+00:00 List-Id: Jeffrey Carter writes: > Ted Dennison wrote: > > > > Generally, I'd agree with you. However, at least one person did use the > > word "unaceptable" when I described the multi-level instantiation > > process a Booch user has to go through. > > I think I used "unacceptable" to refer to the several hours of study > you said was necessary to learn to instantiate a simple data > structure. Multiple instantiations are undesirable, but multiple > instantiations that take hours to learn to use unacceptable. I think it only takes hours the first time (and without any help). >From the documentation: In the example, a Car has three attributes, the Plate (the Index Mark; my first car's was 8493KC), the Model name (it was a Vauxhall Cresta) and the date it was Registered (some time in the mists of antiquity). with Ada.Calendar; with Ada.Strings.Bounded; package Cars is package Plate_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length (10); subtype Plate_String is Plate_Strings.Bounded_String; package Model_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length (32); subtype Model_String is Model_Strings.Bounded_String; type Car is record Plate : Plate_String; Model : Model_String; Registered : Ada.Calendar.Time; end record; end Cars; A company's Fleet holds a number of Cars. The first thing to do is to instantiate the top-level abstract Containers for Car. Note, we have to supply an equality operator ("=") for Car; we could also just use Cars. with BC.Containers; with Cars; package Abstract_Car_Containers is new BC.Containers (Cars.Car, "=" => Cars."="); Next, using the new Abstract_Car_Containers, instantiate the abstract Collections: with Abstract_Car_Containers; with BC.Containers.Collections; package Abstract_Car_Collections is new Abstract_Car_Containers.Collections; You now have to choose the representation to be used for the concrete Collection. To start with, assume that you'll never have more than 30 Cars to deal with. This means that you can use the Bounded form. with Abstract_Car_Collections; with BC.Containers.Collections.Bounded; package Fleets is new Abstract_Car_Collections.Bounded (Maximum_Size => 30); You now need to create your Fleet: with Fleets; package My_Fleet is The_Fleet : Fleets.Collection; end My_Fleet; There, not so bad eh :-)