From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!news.ecp.fr!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: A few questions Date: Tue, 3 Nov 2015 00:33:46 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1446532427 17191 24.196.82.226 (3 Nov 2015 06:33:47 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 3 Nov 2015 06:33:47 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Xref: news.eternal-september.org comp.lang.ada:28187 Date: 2015-11-03T00:33:46-06:00 List-Id: "Simon Wright" wrote in message news:ly1tc8me4w.fsf@pushface.org... > Simon Wright writes: > >> I'd have liked to support >> >> for D in Period loop > > Oops, I meant "for D of Period", i.e. > > for D : Ada.Calendar.Time of Period loop > ... > > but you'd need > > function Constant_Reference > (Container : aliased Date_Container; > Position : Cursor) return Constant_Reference_Type; > > returning > > type Constant_Reference_Type > (Element : not null access constant Ada.Calendar.Time) is private > with > Implicit_Dereference => Element; > > which is clearly meant for actual containers and here would require - I > think - allocating an Ada.Calendar.Time, and of course freeing it > eventually. > > Shame, it makes it tricky to support lazy evaluation. But perhaps we > shouldn't want to ... If you *only* need constants, the Constant_Indexing function can be a normal function (no implicit dereference required). In that case, the implementation will do the memory management. Note the difference in wording between 4.1.6(2/3) and 4.1.6(3/3) (there is no requirement on the return type for Constant_Indexing). OTOH, I think GNAT got that wrong somehow when I constructed an ACATS test to try that (don't recall the details). So it may not work in your copy of GNAT, most likely it will in a future version. Randy.