[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: does anyone else miss a coroutine.reset() feature ?
- From: "Peter Hill" <corwin@...>
- Date: Fri, 7 Feb 2003 17:54:34 +0800
Bilyk, Alex:
> Well, I believe the original message post in this thread specifically
> talked about avoiding creation of new co-routines on reset.
True. However it does seem to be the philosophy of Lua (and this list) that
one should rely on the 'efficient implementation' of Lua to handle
efficiency issues and ignore such micromanagement.
If such efficiency was really a problem then Lua would have moved to
something like reference counting, where one can make efficient reuse of
heap data. For example:
function complex_add(a,b)
if ref(a)==1 then
a.re = a.re + b.re
a.im = a.im = b.im
return a
else
return complex_new(a.re+b.re, a.im+b.im)
endif
end
Of course all this extra complexity of code can be avoided if you have a
nice 'efficient' :-) on-the-fly garbage collection & compation. So we're
back to the original idea of leave-it-to-Lua to handle it.
*cheers*
Peter Hill.