lua-users home
lua-l archive

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


On Mon, Jun 13, 2011 at 3:59 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> o Also, since load is currently the only mechanism to set the _ENV
>> upvalue without using the debug API, I'd like to see a generator for
>> compiled chunks that let you set the _ENV upvalue:
>>
>> function _main (_ENV)
>>   return function (...)
>>      --[[ chunk ]]
>>   end
>> end
>
> Doesn't that seem too specific? ("A mechanism to set the _ENV upvalue of
> binary chunks without using the debug API.") What is wrong with using
> the debug API for this very particular case?

I probably should have emphasized the more important use case: if I
want to use the same compiled chunk as the main function for multiple
threads but with different environments, the only solution is to
recompile the chunk multiple times. This is the case in 5.1 and 5.2.
[Granted you can wrap a chunk in a generator as above, but again, that
only works with regular Lua source. I feel modifying the source
shouldn't be necessary...]

-- 
- Patrick Donnelly