OT: 'best' dynamic language

Manlio Perillo manlio_perillo at libero.it
Wed Apr 23 00:28:03 MSD 2008


Igor Sysoev ha scritto:
> On Tue, Apr 22, 2008 at 03:18:48PM +0200, Manlio Perillo wrote:
> [...]
>>> It does not resolve the problem. The interpreter internally 
>> The Lua interpreter?
> 
> Yes.
> 
>>> must test
>>> result of EVERY function that may fail on memory allocations:
>>>
>>> void *
>>> interpreter_function0()
>>> {
>>>    p = interpreter_function1();
>>>    if (p == NULL) {
>>>        some rollback operations
>>>        return NULL;
>>>    }
>>> }
>>>
>> Not sure to understand, but since memory allocation failure is signaled 
>> via an exception, the code flow is quite different.
>>
>> From http://www.lua.org/source/5.1/ldo.c.html#luaD_rawrunprotected:
>>
>>   struct lua_longjmp lj;
>>   lj.status = 0;
>>   lj.previous = L->errorJmp;  /* chain new error handler */
>>   L->errorJmp = &lj;
>>
>>   LUAI_TRY(L, &lj,
>>     (*f)(L, ud);
>>   );
>>
>>   L->errorJmp = lj.previous;  /* restore old error handler */
>>   if (lj.status != 0) {
>>      ... if memory error, destroy the interpreter
>>   }
>>
>>
>> and:
>> #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
> 
> I understand the exception mechanic, this way is easy to program -
> you do not need to worry about all these tests, but I'm not sure, that
> it is safe way.
> 

Ah, ok.
But do you have doubts only about handling memory allocation failures 
via exceptions, about exception handling in general or about exception 
handling as implemented in Lua?

> 



Manlio Perillo





More information about the nginx mailing list