lua-users home
lua-l archive

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

If try..catch is implemented, I would also like to see a throw() added
(in addition to error()). The function doesn't need to be called
"throw", but its name should not imply error condition. Exceptions might
not be errors, e.g. using an exception to get out of deep recursion, or
for successful program termination [catching it at a high-level pcall(),
of course].

Also, the syntax for generating an exception without appending error
position information is error-prone for coders [it took me a while to
realize that this was supported]:

    error("CatchThis", 0)  --Be prepared for a surprise if you forget
the zero!

Here are two possible suggestions for throw():

(1) Equivalent to this function:

    function throw( object ) error(object, 0) end

(2) Throw could throw any number of objects (not sure what this means
for "catch", though):

    function throw(...) --[[body]] end

John Giors
Independent Programmer
Three Eyes Software

Hi all,

This has certainly been discussed before, e.g a patch:

and also by Metalua, etc.

We have a perfectly decent exception mechanism, but it is awkward to
use. So could at least we have some syntactical sugar over the pcall

steve d.