comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Multiple iterators for a type
Date: Fri, 25 May 2018 16:50:07 -0500
Date: 2018-05-25T16:50:07-05:00	[thread overview]
Message-ID: <pea0eo$cov$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 87o9h3qzv3.fsf@jacob-sparre.dk

Jacob Sparre Andersen" <jacob@jacob-sparre.dk> wrote in message 
news:87o9h3qzv3.fsf@jacob-sparre.dk...
> Lucretia <laguest9000@googlemail.com> 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.




  reply	other threads:[~2018-05-25 21:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 16:49 Multiple iterators for a type Lucretia
2018-05-25 19:50 ` Jacob Sparre Andersen
2018-05-25 21:50   ` Randy Brukardt [this message]
2018-05-26  3:13 ` Stephen Leake
2018-05-26  3:57   ` Luke A. Guest
2018-05-26  4:44     ` Jere
2018-05-26  6:59     ` Dmitry A. Kazakov
2018-05-26 12:33       ` Dan'l Miller
2018-05-26 13:03       ` Lucretia
2018-05-26 13:52         ` Dmitry A. Kazakov
2018-05-26 14:22           ` Dan'l Miller
2018-05-26  7:14     ` G.B.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox