lua-users home
lua-l archive

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


Enrico Colombini <erix@erix.it> writes:

> Tony Finch wrote:
>>   local t = {}
>>   local s = "function f() a = 3 print(a) end"
>>   local chunk = assert(loadstring("in ... do "..s.." end"))
>>   chunk(t)
>
> Yes, that's what Luiz suggested. But it's not exactly efficient (think
> of embedded systems) unless a wrapping loading function is used on the
> C side, as he said. Both techniques are not exactly elegant,
> especially in a clean language like Lua.
>
> Besides, it could be convenient to be able to execute a chunk in
> different environments without reloading it.

Dynamic binding through the environment backdoor has similar bad
consequences on optimization and comprehension as dynamic bindings
through identifiers, I should think.

-- 
David Kastrup