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!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: A few questions Date: Sat, 14 Nov 2015 20:09:56 +0000 Organization: A noiseless patient Spider Message-ID: References: <1dolqizyi8gxi.t3173bhifuu1.dlg@40tude.net> <1705bpj6jrld0.1lc44o5yo6bj7$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="29a2b57997615acde1fccc73c72adb9b"; logging-data="10542"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/hQk0hfQYr9pva9VWC4XCdk47BOUmz3o=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:xhdKGfWD+TARORoM5PEPHPtnNBc= sha1:BZO59ZJ/vfBJekphv7t7NYRgvpY= Xref: news.eternal-september.org comp.lang.ada:28367 Date: 2015-11-14T20:09:56+00:00 List-Id: Shark8 writes: > On Saturday, November 14, 2015 at 5:37:32 AM UTC-7, Simon Wright wrote: >> >> It's a pity that Next takes the iterator object as an 'in' >> parameter. This means that, in general, the cursor needs to hold the >> state. It certainly needs some way of indicating end-of-iteration; >> perhaps a sentinel value. > > Sentinel values, or exceptions? C-style strings use ASCII.NUL as a > sentinel value, and look at the trouble that causes. (Of course part > of that is due to the anemic idea of arrays that C has.) Next (Iterator, Cursor) return Cursor is the operation that would detect End_Of_File or whatever and indicate in the result Cursor that the iteration had ended. Although it would indeed quit the loop, I don't think using an exception would be good (especially in a restricted runtime without exception propagation). If no sentinel value is possible, you're stuck (I think) with type Cursor (Running : Boolean := True) is record case Running is when True => Element : Whatever; when False => null; end case; end record;