lua-users home
lua-l archive

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


Hi,

I find myself writing code that looks a lot like this quite often:

	local foo, err = make_foo()
	if not foo then return nil, err end

	local bar, err = make_err()
	if not bar then return nil, err end

Looking at the output of luac -l, it looks as if this wastes a register
because Lua doesn't reuse the register allocated to the first local
definition containing an "err" for the second, even though the first is
no longer accessible, and never (I think) will become accessible again.

Two questions:
	1) Is there some reason I've missed why it is essential that 
	   Lua behaves this way?
	2) Am I right in thinking that the value stored in the first err
	   will not be garbage collected until the scope containing both
	   errs is left?

B.