lua-users home
lua-l archive

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

On Thu, Jun 5, 2014 at 8:55 AM, Dirk Laurie <> wrote:
> sortedStrings = stringArray:sorted(ALPHABETICALLY)
> When you read that line, no need to wonder what it means.

But I would wonder - for me 'alphabetically' doesn't immediately
connote 'lower case comparison'.

If we only do this once in a file, then it's more convenient to have
the comparison function inline.  Plus, once we start to do more funky
things which can't so easily be expressed by a sensible function name,
then the form is even more convenient.

E.g sorting by length (this is a Nimrod example, another Python-syntax
statically typed compiled language):

sort(cities) do (x,y: string) -> int:
  cmp(x.len, y.len)

I'd still be tempted to create a new function, but its body would
contain the full sort operation....