comp.lang.ada
 help / color / mirror / Atom feed
From: kst@sd.aonix.com (Keith Thompson)
Subject: Re: Design of Ada.Strings.Bounded
Date: 1997/07/16
Date: 1997-07-16T00:00:00+00:00	[thread overview]
Message-ID: <EDFrn2.L3s@thomsoft.com> (raw)
In-Reply-To: mheaney-ya023680001407970241320001@news.ni.net


In <mheaney-ya023680001407970241320001@news.ni.net> mheaney@ni.net (Matthew Heaney) writes:
> In article <EDA684.Dnr@thomsoft.com>, kst@sd.aonix.com (Keith Thompson) wrote:
> >I do wonder, though, why the maximum length of a Bounded_String was
> >made a generic parameter rather than a discriminant.
[...]
> 
> >Was this approach considered?  If so, why was it rejected?
> 
> The reasons for the choice are discussed in the Rationale.

So they are.

> Also, from AARM 95 A.4.4 (1.b):
> 
> Reason: The bound of a bounded-length string is specified as a parameter to
> a generic, versus as the value for a discriminant, because of the
> inappropriateness of assignement and equality of discriminated types for
> the copying and comparison of bounded strings.

Predefined equality isn't a problem, since the package declares its
own "=" function explicitly.

Assignment is a problem, but I'm not convinced that the generic
approach is the best solution.  Currently, assignment between
Unbounded_Strings of different Max_Lengths is illegal, since
they're different types.  (For that matter, two instantations of
Ada.Strings.Bounded.Generic_Bounded_Length with the *same* Max_Length
will create two distinct types.)  With a discriminated type, such an
assignment would be legal, but it would raise Constraint_Error.  (Even
using a controlled type wouldn't solve this.)  If the source and target
Max_Lengths are static, though, the Constraint_Error could be detected
at compile time and the compiler could issue a warning.  I suspect
most instantiations of Ada.Strings.Bounded.Generic_Bounded_Length
use a static value for Max_Length.

In any case, programmers who are really concerned about flexibility
can always use Unbounded_Strings.

-- 
Keith Thompson (The_Other_Keith) kst@sd.aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
5040 Shoreham Place, San Diego, CA, USA, 92122-5989
"Zathras warn Zathras, but Zathras never listen to Zathras." -- Zathras
-- 
Keith Thompson (The_Other_Keith) kst@sd.aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
5040 Shoreham Place, San Diego, CA, USA, 92122-5989
"Zathras warn Zathras, but Zathras never listen to Zathras." -- Zathras




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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
replies disabled

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