|
What I like very much at Lua, and use a lot:
Do you have anything else that comes to your mind? I would also greatly appreciate input regarding other languages that implement these things above and how it's done there. I'm quite fluent in Java, C#, C, _javascript_ and knowledgeable in C++ and PHP. While reflection works in these languages (somehow), it's often requires very arcane knowledge to do similar things as mentioned 1-3.
- 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
or
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)
--
Oliver