On Jun 7, 2010, at 3:36 PM, Niko Schwarz wrote:
On Mon, Jun 7, 2010 at 3:23 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> 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 :)
s stef ? sure ? shit ? huffman encding your programming is a stupid idea.