Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs


More on LinuxToday


Embed Lua for scriptable apps

Jan 29, 2009, 07:33 (0 Talkback[s])
(Other stories by Peter Seebach)

[ Thanks to An Anonymous Reader for this link. ]

"Lua is a small scripting language. How small? Lua uses a custom pattern-matching feature, rather than POSIX regular expressions, because a complete regular expression implementation is substantially larger than all the standard Lua libraries put together; the much simpler string matching provided by Lua, while not quite as powerful, is a fraction of the size.

"Lua variables are not strongly typed; you can check the type of a value, but there is nothing preventing a variable's type from changing over time. Both of these choices are good fits for a scripting language. Lua's type system is reasonably simple, but quite flexible. Arrays and associative arrays are combined into a single type, called tables. Strings, numbers (floating point only), booleans, and the special nil type are basic types. Perhaps more interestingly, functions are also a basic type. You can assign functions to variables as easily as any other type; there is no special syntax. Additional support exists for custom userdata objects, which can be defined by developers to handle types beyond those of the basic system.

"One of the biggest surprises for programmers coming from other languages is that, in Lua, only false and nil are considered false; any object of a non-boolean type is always considered true in tests. While this behavior can surprise people who are used to C idioms, such as using 1 and 0 for true and false, it is easy to adapt to."

Complete Story

Related Stories: