lua-users home
lua-l archive

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


Rici Lake wrote:


Call me slow, but I just noticed that in lua 5.1work6, you can use:

  str:sub(2, 2)

instead of

  string.sub(str, 2, 2)

....

i have been known to set the metatable index of my tables to table :

t = setmetatable({},{__index = table})

then you can say t:insert(xxx), t:concat(), etc.

not quite as efficient as
local tinsert = table.insert --(once only)
tinsert(t,xxx)

but it reads nicely.

i have lines similar to
local gsub, sfind, strlen = string.gsub, string.find, string.len
local min, max = math.min, math.max

in a lot of my lua files; a shortcut "import" or similar would be nice, but not really necessary : i think the above pattern is pretty self-explanatory.

Adrian