lua-users home
lua-l archive

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

Doesn't matter guys, I've got my modified try-catch statement
implemented, and now I'm just left with a weird object retrieval bug
in LVM where changing from checking Lua objects to checking native
exceptions causes the register to be shifted or something, but I can
work that out.

Mostly I don't want to use the anonymous functions / closures methods
because I expect to be using it a lot in the object model I'm pursuing
in the game engine.  More to the point, I don't need to worry about
forcing a specific object model on my users, since the engine already
uses a specific object model to represent it's objects to Lua.  In any
case, users can always make their own object model for their objects
since they can always manually use metatables :), and since that types
are detected using a __type metamethod means that they can make their
objects work with the 'is' operator and the try-catch type evaluation.

Regards, James.

On Mon, Sep 20, 2010 at 6:03 AM, Florian Weimer <> wrote:
> * 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.