lua-users home
lua-l archive

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

In the end it is all a design decision, but a file handle that can error without closing is an incredibly bad idea. returns fd, err for a reason. For a Lua file handle, the handle should always be closed when garbage collected, and if it doesn't, then I think that already qualifies as "doing something dangerous". I think I don't have to explain why throwing an exception while such a file descriptor is open is a bad idea too.

The design decision for Lua was to discourage errors unless they are fatal. Probably because this how it's done in C, too, but also because encouraging exceptions will result in a snowball-effect where half of your code will be exception catching before you know it.

As I already said: try-catch-finally will most likely not be added to Lua, but nothing stops you from rewriting Lua, or writing a new language entirely with these features.