opSlice() magic for foreach now works?

Mafi mafi at example.org
Wed Mar 30 13:35:17 PDT 2011


Am 30.03.2011 20:35, schrieb Jacob Carlborg:
> On 2011-03-30 16:47, David Nadlinger wrote:
>> On 3/30/11 4:43 PM, Jacob Carlborg wrote:
>>> Do we have three ways now to implement iteration, opApply, opSlice and
>>> ranges?
>>
>> Wouldn't opSlice only be syntatic sugar for ranges?
>>
>> David
>
> I have no idea, that's why I'm asking.
>

There are anly two ways to be truly iteratable: opApplay and Ranges. 
Now, if the object does not implememhnt either, opSlice is checked: "Do 
you know somebody that can iterate over you?".
If opSlice (ie a[]) gives something iterable - ie something with 
opApply, a Range or something which itself has a opSlice - the foreach 
is rewritten to use that thing.

Mafi


More information about the Digitalmars-d mailing list