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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,1f0bebbd5edf4a6f X-Google-Attributes: gid103376,public From: Lengyel Sandor Subject: Re: Please help a newbie with Booch/Ada. Date: 1998/08/21 Message-ID: <35DE133E.2B824401@pacbell.net>#1/1 X-Deja-AN: 383512728 Content-Transfer-Encoding: quoted-printable References: <35DCCE3A.9EAE78D8@pacbell.net> Content-Type: text/plain; charset=iso-8859-1 Organization: Pacific Bell Internet Services Mime-Version: 1.0 Reply-To: hunnia@pacbell.net Newsgroups: comp.lang.ada Date: 1998-08-21T00:00:00+00:00 List-Id: Stephen Leake wrote: > = > Lengyel Sandor writes: > = > > I am fooling around with the Booch components, since I think > > "Collections" are very usefull. > = > good idea. > = > > PACKAGE String_References IS > > TYPE String_ptr IS ACCESS ALL String; > > TYPE Const_String_Ptr IS ACCESS CONSTANT String; > > END String_References; > > > > > > Then I created a root_string_container.ads as: > > > > with Bc.Containers; > > with String_References; > > package Root_String_Container is new Bc.Containers > > (String,String_References.String_ptr); > > > > > > (Coping the format of root_container.ads. :-) ) > > > > When I run a semanric check on this later code, I get the following > > message. > > > > root_string_container.ads:4:08: actual for "Item" must be a definite > > subtype. > = > See RM 3.3 (23). Basically, an indefinite type is any unconstrained > type (in this case, String is an unconstrained array). A definite type > is a constrained type. > = > The problem is that the Ada 95 Booch components are modeled after the > C++ Booch components. Since there is no such thing as an "indefinite > type" in C++, the Ada 95 Booch components restrict you to definite > types. This is one of the advantages of Ada 95 over C++; you can give > more information about the type. On the other hand, a careless library > author can shoot you down. > = > As a work around, you can use Ada.Strings.Unbounded.Unbounded_String > instead of String. > = > Better would be to fix the Ada 95 Booch components to allow indefinite > types. Find the declaration of Bc.Containers, and add "(<>)" as a > discriminant to the object type. Be aware this might break lots of > stuff; I haven't tried it. > = > -- Stephe At work I tried the Bounded_String approach, (before I read this letter), and I got it working. I am not impressed with the booch components so far. I had to create quite a few new packages. Now that it is done, it is easy to use. = I don't know much about Ada, but feel that redoing the object types as you suggested, should have been the way to go. There should be a collection library more general and easier to use. Is there one? Also the documentation for the Booch components is almost non existent. Maybe it is enough for an expert, but I spent 1 day to get it working for Strings. Sandor -- = Lengyel S=E1ndor Hass, alkoss, gyarapits, S a haza f=E9nyre der=FCl. (K=F6lcsey)