comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Returning ranges from a function (was: How to loop (elegant) throug a vector ?)
Date: Sun, 22 Jun 2008 07:01:11 -0700 (PDT)
Date: 2008-06-22T07:01:11-07:00	[thread overview]
Message-ID: <6ebe0cd8-288e-4997-94d7-61905fd2dfc0@r66g2000hsg.googlegroups.com> (raw)
In-Reply-To: 20080620191237.5971480b@cube.tz.axivion.com

On 20 Cze, 19:12, Stefan Bellon <bel...@software-erosion.org> wrote:

> Now you can do the following:
>
>    function Get_Range
>      return Integer_Range_Objects.Range_Type
>    is
>    begin
>       return (42 .. 128 => <>);
>    end Get_Range;
>
> And then:
>
>    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.
It would be nicer to return a "range" that is not dependent on memory
constraints. See xrange in Python.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



  reply	other threads:[~2008-06-22 14:01 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 [this message]
2008-06-22 18:47     ` Stefan Bellon
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