What I like very much at Lua, and use a lot:
- you can use anything as index in a table, including other tables, functions, coroutines, and userdata, like sockets.
This saves a lot of CPU time when managing these resources
- multiple vale assignment, and especiall the fact that functions may return multiple values like
a,b = b,a
angle, radius = toPolar( x,y )
- closures are great for, e.g. scheduling actions, as parameter for pattern substitution, iterators, etc.
once I got the concept, I don't want to miss them again.
- string.gsub() is one of the best find and replace implementations I came across in my not too short programming history.
Not even that one can use a function (more precisely a closure) as parameter for the substitution, a table is fun enough.
It is not often that a UTF-8 to something else conversion is a one-liner:
win1252 = utf8:gsub( '[\xc0-\xef][\x80-\xbf]+', utf8ToWin1252 )
(utf8ToWin1252 is a table with the UTF8 encoding as keys and the win-1252 encoding as values)