comp.lang.ada
 help / color / mirror / Atom feed
From: Stefan Bellon <bellon@software-erosion.org>
Subject: Re: Returning ranges from a function (was: How to loop (elegant) throug a vector ?)
Date: Sun, 22 Jun 2008 20:47:13 +0200
Date: 2008-06-22T20:47:13+02:00	[thread overview]
Message-ID: <20080622204713.2127db4f@cube.tz.axivion.com> (raw)
In-Reply-To: 6ebe0cd8-288e-4997-94d7-61905fd2dfc0@r66g2000hsg.googlegroups.com

On Sun, 22 Jun, Maciej Sobczak wrote:
> On 20 Cze, 19:12, Stefan Bellon <bel...@software-erosion.org> wrote:

> >    for I in Get_Range'Range loop
> >       Do_Something (I);
> >    end loop;
> >
> > It's not as elegant as I wished (because of the additional 'Range),
> > but it is simple and light-weight enough to be usable.
> 
> As far as I can tell, it creates the physical array that might not be
> necessarily optimized out by the compiler. You need to store it
> somewhere.

You need to store the two words for First and Last (or First and
Length). And indeed, this is what GNAT does. The 'Size of the array
object returned is two words in size.

> It would be nicer to return a "range" that is not dependent on memory
> constraints. See xrange in Python.

I think you cannot get smaller than the two words. The question is
whether this optimisation (for 'Size use 0) can always be guaranteed.

-- 
Stefan Bellon




  reply	other threads:[~2008-06-22 18:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20 13:19 How to loop (elegant) throug a vector ? Reinert Korsnes
2008-06-20 14:49 ` Pascal Obry
2008-06-20 17:12 ` Returning ranges from a function (was: How to loop (elegant) throug a vector ?) Stefan Bellon
2008-06-22 14:01   ` Maciej Sobczak
2008-06-22 18:47     ` Stefan Bellon [this message]
2008-06-22 21:06       ` Maciej Sobczak
2008-06-23  9:47         ` Stefan Bellon
2008-06-23 12:06           ` Maciej Sobczak
2008-06-23 12:28             ` christoph.grein
2008-06-20 19:21 ` How to loop (elegant) throug a vector ? Jeffrey R. Carter
2008-06-20 19:48   ` Reinert Korsnes
2008-06-20 23:25     ` Jeffrey R. Carter
2008-06-23 17:14     ` Matthew Heaney
2008-06-23 17:11   ` Matthew Heaney
2008-06-23 17:08 ` Matthew Heaney
replies disabled

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