lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On 20/02/2012 5:30 AM, Dirk Laurie wrote:
The List metatable would contain the standard table library and some ml
functions, plus 'sorted' (so that L:sorted() not only sorts L, but also
returns it).

Playing the naming game:

Qt has this convention where verbs like sort() are mutators that act on the instance (ie the name means "_sort_ myself", adjectives like sorted() return a sorted *copy* of the collection (ie the name means "return a _sorted_ version of self" it's an adjective). Other examples: translate(), translated().

I like this convention, just just because I'm a heavy Qt user, but because it makes sense.

I would find it kind of weird if sorted() just returned a copy of self, if that's the desire, I'd say it's better to have sort() return itself. sorted() should make a sorted copy.

Just my two cents.. take or leave,

Best wishes

Ross.