lua-users home
lua-l archive

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


Hi

As for pros, not allowing keywords in these situations sometimes leads
to situations with contrived names (such as `bit32.band`...), and I
had to uglify my code in the past with `bla.["keyword"]` in situations
where all other uses of bla were nicely `bla.field`. On the other
hand, I wouldn't like the inconsistency of being able to use `x` to
write `bla.x`, `{ x = 123 }`, `function x()`, `x()`; but then being
able to use `and` to write `bla.and`, `{ and = 123 }`, `function
and()` but not `and()`.

This is the main reason I support this change: because some keywords
would otherwise be natural field names in a data table or object.
"end" is one that I ran into while developing something for my
matchext library, and instead of using "start" and "end" as fields for
the start and end positions of a match, I ended up having to use
"startpos" and "endpos". The ability to use "end" as a field name
would be nice.
But you could use "End" or "END", don't you?

Since I usually do something like:

local gsub = require"string".gsub

It would be natural to try:

local end = require"your_lib".end

Which would not be allowed, I suppose.  Also, I cannot feel comfortable
writing something like:

{
  start = function ()
    ...
  end,
  end = function ()
    ...
  end,
}

This seems weird!

Maybe it is just me, but I think Lua is better the way it is :-)

Regards,
Tomás