comp.lang.ada
 help / color / mirror / Atom feed
From: Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU>
Subject: Design of Ada.Strings.Bounded
Date: 1997/07/11
Date: 1997-07-11T00:00:00+00:00	[thread overview]
Message-ID: <5q4mel$16r$1@goanna.cs.rmit.edu.au> (raw)


After contemplating how i would use Ada.Strings.Bounded, i wondered about
the decisions that were made when it was designed. 

If I use it in a package, and want to add any additional features, or
use it as a parameter type

e.g. 
	function Check_Spelling (Item : Bounded_80) return Boolean;

then this is rather unfortunate when i want to check the spelling 
of an item in a Bounded_81 string. This is exactly the same problem
that we had in Pascal, that unconstrained types in Ada solved.

One possible design that would have solved this problem is to have
Ada.Strings.Bounded declare and abstract tagged type, with all of the
subprograms declared abstract, and a small generic package with the
type inside.

e.g.

	package Ada.String.Bounded is
	   type Bounded_String is abstract tagged private;
	   
	   function Length (Item : Bounded_String) return Natural is abstract;
	   function Max_Length (Item : Bounded_String).... is abstract;
	   ...
	   
	   generic
	      Max : Positive;
	   package Generic_Bounded_Length is
	      ...
	      type Bounded is new Bounded_String with private;
	      ...
	   end Generic_Bounded_Length;
	
	end Ada.Strings.Bounded;


This would at least allow class wide programming for functions such as
Check_Spelling above.

Dale




             reply	other threads:[~1997-07-11  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-11  0:00 Dale Stanbrough [this message]
1997-07-11  0:00 ` Design of Ada.Strings.Bounded Matthew Heaney
1997-07-13  0:00 ` Keith Thompson
1997-07-14  0:00   ` Matthew Heaney
1997-07-16  0:00     ` Keith Thompson
replies disabled

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