John Belmonte |
|
|
* [scope exit hooks] (Lua 5.4 to-be-closed variables) |
|
I wrote a chapter in [Lua Programming Gems] on exceptions. I presented [Exception patterns in Lua] at the second Lua workshop, in 2006. |
|
Presentations / publications * article: [Structured concurrency and Lua] (2022) * chapter: Exceptions in Lua, [Lua Programming Gems] (2008) * presentation: [Exception patterns in Lua], second Lua workshop (2006) |
|
== PROJECT IDEAS == These are in order from impossible to really-impossible. I hope someone does this stuff so I don't have to. * Lua-based build system - something like Jam [1] could be done ten times better using Lua. It would also allow programs using Lua to easily share info with the build system... a big win for managing complex program data. (See LuaBuildSystems) * alternate implementation of Lua in D - (someone has finally attempted, see [Lua-D]) |
|
* No scope hook metamechanism. Many applications expose scarce resources to the scripting environment such as locks; handles for files, memory, and database transactions; etc. Such resources need to be released promptly and deterministically after use, and despite any exceptional condition in the program. Of course this can be accomplished with Lua as it is, but the resulting code is hard to follow, highly error prone, and makes heavy use of protected calls-- limiting potential use of coroutines. This could be resolved if Lua provided a way to hook into scope exit events. See [Lua: Improving deterministic resource cleanup]. (Covered by Lua 5.4 "to-be-closed" variables.) |
|
* No scope hook metamechanism. Many applications expose scarce resources to the scripting environment such as locks; handles for files, memory, and database transactions; etc. Such resources need to be released promptly and deterministically after use, and despite any exceptional condition in the program. Moreover, Python's context managers (`with` statement) demonstrate endless uses for such a feature. Of course this can be accomplished with Lua as it is, but the resulting code is hard to follow, highly error prone, and makes heavy use of protected calls-- limiting potential use of coroutines. This could be resolved if Lua provided a way to hook into scope exit events. See [Lua: Improving deterministic resource cleanup]. (Covered by Lua 5.4 "to-be-closed" variables.) |
Lua-user, man behind the wiki curtain. (Challenge: say "lua-users" ten times fast.)
I've influenced Lua by successful lobbying for:
__tostring on display of error objects (Lua 5.2)
Presentations / publications
My Pages (or at least pages I started)
My posts to lua-l [1]
Favorite lua-users wiki pages
lua-users.org is...
I think Python PEP's [3] are a great source of info. Find out where Python was flawed and how it's being fixed. Learn about Python's implementations of the latest language fads.
I'd like to mention a wonderful property of (most) wiki implementations that may not be entirely obvious. They forget the past. Although an edit history is maintained for each page, it fades out over time. So deleted mistakes, unkind words, and useless material really disappear unless someone explicitly acts to revive or archive them. This is quite a different concept from the mailing list or newsgroup where, in the case of a public forum, every word may likely be archived until the end of civilization. An interesting article related to this subject is In Defense of the DELETE Key [4].
Here's how to use the unix wget command to make a static copy of this wiki for offline browsing. Of course you can't edit or search the wiki when offline, so that takes the fun out of things.
wget --mirror --html-extension --convert-links http://lua-users.org/wiki/
table.pack in Lua 5.2 will cover sequence-only tables.)
for i=1,getn(t)" idiom is verbose and when used carelessly requires a global table lookup per item. The foreachi idiom is not efficient due to extra function call overhead per item, and not concise due to the need to define a function object. I have implemented a new for construct as a solution, see LuaPowerPatches. (As of Lua 5.1, the idoms have changed but the issue still stands. We now have "for i=1,#t" or "for _,item in ipairs(t)".)
These points are ugly but tolerable:
Historical warts which have been resolved:
a = 5
globals().a = 5
lua_tostring does not honor __tostring metatable hook. lua_tostring in the C API and tostring in the base Lua library are not equivalent. The former does not honor the __tostring hook, which is important for debug and error output of user defined types, and in general the emulation of strings with user types. As an example of the problem, the lua command line interpreter uses lua_tostring in the case of uncaught exceptions, leaving no way to communicate the details of non-string exception objects to the user. (In Lua 5.2 there is a separate function luaL_tolstring which honors __tostring, and interpreter exception handler appears to use this.)
string.format %s does not invoke tostring. (Fixed in Lua 5.2.)