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!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: First and Next vs Has_Element Date: Thu, 17 Nov 2016 15:43:27 -0600 Organization: JSA Research & Innovation Message-ID: References: NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1479418958 26833 24.196.82.226 (17 Nov 2016 21:42:38 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 17 Nov 2016 21:42:38 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:32365 Date: 2016-11-17T15:43:27-06:00 List-Id: "Victor Porton" wrote in message news:o0kf8e$pct$1@gioia.aioe.org... > Why in "5.5.1 User-Defined Iterator Types" First and Next are regular > routines but Has_Element is generic formal parameter? Has_Element is strictly a function of the Cursor type (it serves the same purpose as comparing a pointer to null). First and Next are functions of the iterator - that is the state of the iterator can have an effect on their results. (Typically, in fact, the iterator will contain a reference to the container being iterated, so such state is necessary). We could have included Has_Element in the interfaces, but that would have been artifical, as it should not reference the iterator state at all. Note that there aren't any "regular routines" here; First and Next are abstract routines that have to be implemented by the type derived from the interface. Also, as a practical matter, we wanted the Has_Element here to match the profile of the one in each of the container's packages. And those only take a cursor parameter. Randy.