lua-users home
lua-l archive

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

Hash: SHA1

On 09/01/10 09:55, steve donovan wrote:
> For instance, many of us crave a straightforward try..except
> construct, although we're fully aware that it is sugar for pcall().
> (A straightforward implementation of try..except is possible, except
> that it's hard to detect whether a function issued an explicit return
> or not)

As an aside, I actually did this for Objective Lua --- you can return
from inside the try or catch and it all works correctly.

However, this raised some design issues about what to do with the
exception once you've caught it. As Lua tends to throw strings for
run-time errors, you need an annoying amount of boilerplate to first
check to see if the exception is an object, then to check to see if the
exception supports an interface you understand, then to check to see if
the exception is the one you actually wanted --- every time.

So just supporting try...catch isn't quite enough to make exceptions
work. We also need the infrastructure to make exceptions meaningful,
which requires additional thought.

Of course, now I'm going to have to rewrite Objective Lua to work with

- -- 
┌─── ───── ─────
│ "Under communism, man exploits man. Under capitalism, it's just the
│ opposite." --- John Kenneth Galbrith
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -