On 2010-02-15 09:04:11 -0500, Leandro Lucarella <llu...@gmail.com> said:

Andrei Alexandrescu, el 14 de febrero a las 20:24 me escribiste:
There are two operations: reverse the thing in place, and span it in
retrograde order.

I think reverse (in-place) and reversed (returns a range that iterates in
reverse order) are *very* clear in terms of that distinction.

But now how do you distinguish between a function returning the reversed form of something and a function returning true when that thing is reversed?

:-)

In Ruby syntax things are generally pretty easy:

        something.reverse!  # reverse in place ('dangerous!' method)
        something.reverse   # reverse a copy
        something.reversed? # return whether something is reversed or not

Cocoa would use a slightly different notation:

        [something reverse];           // reverse in place
        [something reversedSomething]; // reverse a copy
        [something isReversed];        // return whether something is reversed 
or not

Both conventions are very clear and scale well even for words like 'split' which are identical in their past and present tense.

It's unclear to me how we want this to be done in D...

        something.reverse();  // reverse in place
        something.reversed;   // reverse a copy
        something.reversed(); //   ditto
        something.reverse();  //   ditto
        something.reversed;   // return whether something is reversed or not
        something.isReversed; //   ditto

If we want some consistency, someone with authority over Phobos will have to draw some guidelines about this, and sooner the better.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to