On Wed, 7 Mar 2012, Randy Brukardt wrote:
> "Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
> > firstname.lastname@example.org writes:
> >> procedure Sort(Items: in out array(generic Positive range <>) of T) is
> > Interesting idea.
> Can't you do this with a type conversion to an appropriate constrained array
> subtype? (Such conversions slide.) I suppose it could be a pain to declare
> such a subtype in front of every call, but it is a trick I've used a some
> cases (usually in wrappers) to force sliding on arguments.
Can you explain a bit more?
> I suppose a more convinient way to force that would be helpful.
Beyond the inconvenience, there are two further issues:
When you declare
procedure Sort(Items: in out array(Positive range <>) of T)
in a package specification, and you try to write a proper black-box test,
you need *more* test cases then when you do the same with another popular
language. One of the additional test cases could look like
X: array (Positive range Positive'last-2 .. Positive'Last) := ...;
Y: array (Positive range Positive'last-2 .. Positive'Last) := ...;
Some time ago, I have actually been bitten by forgetting such a test case.
So the sad reality is that there is a property where Ada makes testing
harder than, say, C or C++.
Given the (Ada 2020?) specification
procedure Sort(Items: in out array(generic Positive range <>) of T);
Sort(X) should be callable if the index type of X is any discrete type,
except when the index type is too large (i.e., X has more than
---- Stefan.Lucks (at) uni-weimar.de, University of Weimar, Germany ----
------ I love the taste of Cryptanalysis in the morning! ------