From: stefan-lucks@see-the.signature
Subject: Re: Array Help?
Date: Thu, 8 Mar 2012 12:20:28 +0100
Date: 2012-03-08T12:20:28+01:00 [thread overview]
Message-ID: <Pine.LNX.4.64.1203081150460.6571@medsec1.medien.uni-weimar.de> (raw)
In-Reply-To: <jj8snn$8n7$1@munin.nbi.dk>
On Wed, 7 Mar 2012, Randy Brukardt wrote:
> "Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
> news:wccy5rls0hl.fsf@shell01.TheWorld.com...
> > stefan-lucks@see-the.signature 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:
1. Testing
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
declare
X: array (Positive range Positive'last-2 .. Positive'Last) := ...;
Y: array (Positive range Positive'last-2 .. Positive'Last) := ...;
begin
Sort(X);
Assert(X=Y);
end;
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++.
2. Generality
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
Positive'Last elements).
--
---- Stefan.Lucks (at) uni-weimar.de, University of Weimar, Germany ----
<http://www.uni-weimar.de/cms/medien/mediensicherheit/home.html>
------ I love the taste of Cryptanalysis in the morning! ------
next prev parent reply other threads:[~2012-03-08 11:13 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-28 20:15 Array Help? Will
2012-02-28 20:47 ` Ludovic Brenta
2012-02-28 22:11 ` Simon Wright
2012-02-28 23:09 ` Will
2012-02-29 0:24 ` Adam Beneschan
2012-02-28 20:50 ` Gautier write-only
2012-02-28 21:33 ` Simon Wright
2012-02-29 0:27 ` Adam Beneschan
2012-02-29 8:00 ` Simon Wright
2012-02-29 8:48 ` Simon Wright
2012-02-29 0:22 ` Adam Beneschan
2012-02-29 16:09 ` Robert A Duff
2012-02-29 16:50 ` Ludovic Brenta
2012-02-29 18:24 ` Robert A Duff
2012-02-29 19:45 ` stefan-lucks
2012-02-29 20:45 ` Jeffrey Carter
2012-02-29 21:27 ` stefan-lucks
2012-02-29 23:06 ` Robert A Duff
2012-03-02 13:45 ` stefan-lucks
2012-03-07 23:58 ` Randy Brukardt
2012-03-08 11:20 ` stefan-lucks [this message]
2012-03-09 2:02 ` Randy Brukardt
2012-03-09 8:48 ` stefan-lucks
2012-03-09 21:10 ` Randy Brukardt
2012-03-15 2:55 ` BrianG
2012-03-15 7:46 ` stefan-lucks
2012-02-29 20:07 ` Dmitry A. Kazakov
2012-02-29 23:15 ` Robert A Duff
2012-03-01 8:54 ` Dmitry A. Kazakov
2012-03-01 14:06 ` Robert A Duff
2012-02-29 20:47 ` Simon Wright
2012-02-29 22:23 ` Robert A Duff
2012-02-29 23:27 ` Robert A Duff
2012-03-01 0:53 ` Adam Beneschan
2012-03-01 7:16 ` Ludovic Brenta
2012-03-01 14:03 ` Robert A Duff
2012-03-08 0:11 ` Randy Brukardt
2012-03-08 0:08 ` Randy Brukardt
2012-02-29 23:30 ` Simon Wright
2012-02-29 18:35 ` Jeffrey Carter
2012-02-29 22:59 ` Robert A Duff
2012-02-29 23:51 ` Jeffrey Carter
2012-03-01 3:03 ` Robert A Duff
2012-02-29 20:40 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox