comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <jrcarter@acm.org>
Subject: Re: Ada.Containers.Indefinite_Doubly_Linked_Lists
Date: Mon, 05 Feb 2007 18:33:07 GMT
Date: 2007-02-05T18:33:07+00:00	[thread overview]
Message-ID: <DLKxh.1174366$084.565534@attbi_s22> (raw)
In-Reply-To: <mailman.71.1170697701.18371.comp.lang.ada@ada-france.org>

Carroll, Andrew wrote:
> 
> Type Attribute is record
> 	Name: String(50);
> 	Type: String(25);

Type, of course, is a reserved word. String is an unconstrained array 
type, and needs to be constrained by a range:

Name : String (1 .. 50);

Note that Name will always be 50 characters. If you want Names of 
varying lengths, Unbounded_String is probably the easiest way to go.

> I'm kind of lost though as to where these package declarations should
> go.  Should they be like:
> 
> Package Table_List_Thingy is
> 
> 	Type Attribute is record
> 		Name: String(50);
> 		Type: String(25);
> 		...
> 	End record;
> 
> 	Package Attribute_List is new new
> Ada.Containers.Indefinite_Doubly_Linked_Lists (Attribute);
> 
> OR
> 
> Procedure RunMe(...) is 
> 
> 	Type Attribute is record
> 		Name: String(50);
> 		Type: String(25);
> 		...
> 	End record;
> 
> 	Package Attribute_List is new new
> Ada.Containers.Indefinite_Doubly_Linked_Lists (Attribute);

Yes. Either will work. Which you should use depends on the problem and 
your design. (Here we encounter one of Ada's most valuable features: you 
have to think about design before you start coding.)

It doesn't look as if you need the indefinite version for either of your 
lists.

-- 
Jeff Carter
"Spam! Spam! Spam! Spam! Spam! Spam! Spam! Spam!"
Monty Python's Flying Circus
53



  reply	other threads:[~2007-02-05 18:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-05 17:47 Ada.Containers.Indefinite_Doubly_Linked_Lists Carroll, Andrew
2007-02-05 18:33 ` Jeffrey R. Carter [this message]
2007-02-05 20:39 ` Ada.Containers.Indefinite_Doubly_Linked_Lists Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox