comp.lang.ada
 help / color / mirror / Atom feed
* Design of Ada.Strings.Bounded
@ 1997-07-11  0:00 Dale Stanbrough
  1997-07-11  0:00 ` Matthew Heaney
  1997-07-13  0:00 ` Keith Thompson
  0 siblings, 2 replies; 5+ messages in thread
From: Dale Stanbrough @ 1997-07-11  0:00 UTC (permalink / 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




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1997-07-16  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-07-11  0:00 Design of Ada.Strings.Bounded Dale Stanbrough
1997-07-11  0:00 ` Matthew Heaney
1997-07-13  0:00 ` Keith Thompson
1997-07-14  0:00   ` Matthew Heaney
1997-07-16  0:00     ` Keith Thompson

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