From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: Please help a newbie with Booch/Ada.
Date: 1998/08/27
Date: 1998-08-27T00:00:00+00:00 [thread overview]
Message-ID: <x7v4suygbov.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: upvducc1i.fsf@gsfc.nasa.gov
Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:
> Lengyel Sandor <hunnia@pacbell.net> 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.
This was my recommendation to another user.
> 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.
This is a possibility, but since the components require the generic
type Item to be copyable I don't think it will work?
A fix for Lengyel would be to declare
type String_ptr_ptr ias access String_ptr;
and instantiate with
package Root_String_Container is new Bc.Containers
(String_References.String_ptr, String_References.String_ptr_ptr);
I have in mind that this instantiation with 2 pointers is confusing
and tedious, as far as I can see at the moment it's there to support
iterators where the iterating procedure can modify the item;
function Current_Item (Obj : Iterator) return Item_Ptr;
and
generic
with procedure Apply (Elem_Ref : in Item_Ptr; OK : out Boolean);
function Modify (Obj : access Passive_Iterator) return Boolean;
I think both of these would be better Ada if they used in out
parameters, eg
generic
with procedure Apply (Elem : in out Item; OK : out Boolean);
function Modify (Obj : access Passive_Iterator) return Boolean;
next prev parent reply other threads:[~1998-08-27 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-08-20 0:00 Please help a newbie with Booch/Ada Lengyel Sandor
1998-08-21 0:00 ` Stephen Leake
1998-08-21 0:00 ` Lengyel Sandor
1998-08-27 0:00 ` Simon Wright [this message]
1998-08-30 0:00 ` Matthew Heaney
1998-09-01 0:00 ` Brian Rogoff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox