comp.lang.ada
 help / color / mirror / Atom feed
From: Pascal Obry <pascal@obry.net>
Subject: Re: Normalizing array indices
Date: Sat, 29 Oct 2011 09:29:13 +0200
Date: 2011-10-29T09:29:11+02:00	[thread overview]
Message-ID: <4eabab47$0$30757$ba4acef3@reader.news.orange.fr> (raw)
In-Reply-To: <j8f5up$cg5$1@munin.nbi.dk>

Le 28/10/2011 23:13, Randy Brukardt a écrit :
> I probably would constrain the parameter to have a lower bound of 1. Using
> Ada 2012:
>
> generic
>     type Element_Type is private;
>     type Sort_Array_Type is array (Positive range<>) of Element_Type;
>     with function "<" (Left, Right: Element_Type) return Boolean is<>;
> procedure Sort(A: in out Sort_Array_Type)
>     with Pre =>  A'First 1;

Or maybe something less radical:

generic
     type Element_Type is private;
     type Sort_Array_Type is array (Positive range<>) of Element_Type;
     with function "<" (Left, Right: Element_Type) return Boolean is<>;
procedure Sort(A: in out Sort_Array_Type)
     with Pre =>  A'Last < Positive'Last - 1;

I think this covers the problem expressed by the OP, right?

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B




  reply	other threads:[~2011-10-29  7:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28 18:58 Normalizing array indices Stefan.Lucks
2011-10-28 20:36 ` Adam Beneschan
2011-11-01 20:18   ` Stefan.Lucks
2011-10-28 21:13 ` Randy Brukardt
2011-10-29  7:29   ` Pascal Obry [this message]
2011-10-29 19:18     ` Jeffrey Carter
2011-10-29 19:58       ` tmoran
2011-10-29 21:15         ` Simon Wright
2011-10-29 20:41       ` Randy Brukardt
2011-11-01 20:49         ` stefan-lucks
2011-11-01 20:44     ` stefan-lucks
2011-11-01 20:43   ` stefan-lucks
2011-11-02 12:16     ` Robert A Duff
2011-10-29  9:05 ` Simon Wright
2011-10-29  9:23   ` Dmitry A. Kazakov
2011-11-01 20:55   ` stefan-lucks
2011-11-02 12:14   ` Robert A Duff
replies disabled

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