On Mon, Jun 7, 2010 at 3:23 PM, Stéphane Ducasse
<[email protected]> wrote:
> yes this one looks good.
> but
>
>        copyFrom: 1 to: does not convey that you should pass the second 
> argument starting reverse.

Well, in ruby it's a general convention that negative indices start
counting from the right. A reasonable implementation would change all
sequenceable collections such that they accept negative indices.

In Phexample syntax:

((1 to: 5) at: -2) should = 4.

The alternative is to always have two accessors, then of course non-negative:

(1 to: 5) atFromEnd: 2)  should = 4.

and:

('hello' from: 2 toFromEnd: 2) should = 'ell'

I clearly prefer the negative indices. Things you do all the time can
be much shorter than things you don't do so often. Huffman-encode your
programming :)

Cheers,

Niko


-- 
http://scg.unibe.ch/staff/Schwarz
twitter.com/nes1983
Tel: +41 076 235 8683

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to