lua-users home
lua-l archive

Re: Modifing try-catch statement

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


* James Rhodes:
> However, I want to modify the try-catch so that it can be of the form:
>
> try
> -- attempt code
> catch (Engine.DivideByZeroException e) do
> -- catch Engine.DivideByZeroException
> catch (Engine.Exception e) do
> -- catch Engine.Exception
> end
What about using guards?
 try
 -- attempt code
 catch e if is(e, Engine.DivideByZeroException) then
 -- catch Engine.DivideByZeroException
 catch e if is(e, Engine.Exception) then
 -- catch Engine.Exception
 end
I think the syntax is still sufficienty concise.
If you follow this path, you don't have to force a particular object
system on users.

AltStyle によって変換されたページ (->オリジナル) /