← Back to team overview

ooc-dev team mailing list archive

Re: Back/front methods for Iterable (and reverse iterators)

 

I like the proposal of Rubin.

Maybe iterator should be iterable? (they would just return themselves)

In that case we could write:

for(element in list backward())
>

And ex-Java programmers could even write

for(element in list forward())
>

If they wanted.

Amos

On Fri, May 28, 2010 at 5:59 PM, cd rubin <launchpad@xxxxxxxxxxxxxxxx>wrote:

>
> Hey all
>
> In which case shouldn't the methods be called 'forwards' and 'backwards'? I
> think that fits better with the language :
>
> "iterate over a list backwards"
>
> iter := list backwards()
>
> and it removes possible confusion stemming from calling the method 'front'
> and getting an iterator instead of the first item of the list!
>
>  - Daniel (cdrubin)
>
> On Fri, May 28, 2010 at 11:21 AM, Josh Roesslein <jroesslein@xxxxxxxxx>wrote:
>
>> Bart makes a good point that not all Iterables will have an ordered
>> structure (ex: socket input/output streams).
>> I think it would make more sense having front() and back() methods in List
>> that returns Iterators that either traverse
>> the list head to tail or vice versa.
>>
>> Josh
>>
>> On Fri, May 28, 2010 at 9:33 AM, Amos Wenger <amoswenger@xxxxxxxxx>wrote:
>>
>>> So what then? iterator~back() ?
>>>
>>>
>>> On Fri, May 28, 2010 at 2:53 PM, Bart van der Werf <bluelive@xxxxxxxxx>wrote:
>>>
>>>> I'm not sure.
>>>>
>>>> Alot of iterables have no order, so if front/back is the default way to
>>>> get an iterator it would make little sense.
>>>>
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~ooc-dev<https://launchpad.net/%7Eooc-dev>
>>> Post to     : ooc-dev@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~ooc-dev<https://launchpad.net/%7Eooc-dev>
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~ooc-dev<https://launchpad.net/%7Eooc-dev>
>> Post to     : ooc-dev@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~ooc-dev<https://launchpad.net/%7Eooc-dev>
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~ooc-dev<https://launchpad.net/%7Eooc-dev>
> Post to     : ooc-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ooc-dev<https://launchpad.net/%7Eooc-dev>
> More help   : https://help.launchpad.net/ListHelp
>
>

Follow ups

References