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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Multiple iterators for a type Date: Fri, 25 May 2018 16:50:07 -0500 Organization: JSA Research & Innovation Message-ID: References: <87o9h3qzv3.fsf@jacob-sparre.dk> Injection-Date: Fri, 25 May 2018 21:50:16 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="13087"; mail-complaints-to="news@jacob-sparre.dk" 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.7246 Xref: reader02.eternal-september.org comp.lang.ada:52684 Date: 2018-05-25T16:50:07-05:00 List-Id: Jacob Sparre Andersen" wrote in message news:87o9h3qzv3.fsf@jacob-sparre.dk... > Lucretia writes: > >> I want to have a type which is an array of 8 bit values, I want the >> default iterator to be the normal array loop. >> >> But then I want to add more iterators which return different types but >> constructed from the array, i.e. a 32-bit value and a sub-array. >> >> 1. Can this be done on the base type or do I need to create new types >> from the base type? > > It can be done on the base type. There can only be one "of" iterator, and it's built-in for array types. To replace the "of" iterator you need different private types (which means of course that they can't directly be used as arrays, either, although you can emulate that). Why you'd want to go through that escapes me. You can explicitly use alternate iterators using the "in" syntax. After all, any iterator object can be iterated (duh!), and you can create as many different ones of those as you want/need. The "of" iterator is just a convinience, and I think the language would have been just fine without it. Ignore its existence and you'll be just fine and can have all of the iterators you ever could need. Randy.