opSlice() magic for foreach now works?

Jacob Carlborg doob at me.com
Thu Mar 31 08:50:58 PDT 2011


On 2011-03-30 22:35, Mafi wrote:
> 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

Ok, thanks.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list