Super-dee-duper D features
kris
foo at bar.com
Tue Feb 13 17:14:32 PST 2007
Bill Baxter wrote:
> kris wrote:
>
>> kris wrote:
>>
>>> Bill Baxter wrote:
>>>
>>>> Frits van Bommel wrote:
>>>>
>>>>> By the way, would the new loop syntax allow more than two
>>>>> collections to be simultaneously iterated?
>>>>
>>>>
>>>>
>>>>
>>>> Whoa! I certainly hope so. It hadn't even occurred to me that
>>>> Andrei might mean this syntax can only be used for just two
>>>> collections. If that's the case then ... ick.
>>>>
>>>> --bb
>>>
>>>
>>>
>>> InterleavedIterator does multiple collections via using multiple
>>> instances of InterleavedIterator. It's simple to use, and only needs
>>> to be written once. Would be better to implement some basic iterator
>>> needs than to introduce some tricky new syntax?
>>>
>>> - Kris
>>
>>
>>
>> Should have given an example. Simple case with 2 entities:
>>
>> auto two = InterleavedInterator (x, y);
>> foreach (x; two) ...
>>
>> more than 2:
>>
>> auto three = InterleavedInterator (two, z);
>> foreach (x; three) ...
>
>
> Should have also mentioned where one can find this mythical
> InterleavedIterator.
>
> --bb
There is no 'standard' one at this time that I know of (judging by the
discussion on it a while back). However, Tango does have this beastie in
the collections package. The point is, coming up with a lightweight core
Iterator approach would likely provide a simpler and more dependable
solution.
in the above example, x, y, and z are all iterators themselves. If D had
a core notion of Iterator, that's what those would be. For instance, D
iterators might map to a delegate (which is what the body of a foreach
actually is).
More information about the Digitalmars-d
mailing list