lua-users home
lua-l archive

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

On 12 Jan 2010 16:25:46 +0100
Roberto Ierusalimschy <> wrote:


I too was sad to see those function go as I frequently use them to
isolate data (formated as lua code) loading in my games.
I should be able to work around it though :)

Anyway I understand what you're saying and it does sound good.

>   code = "string with the code to be loaded"
>   f = loadstring("in ... do " .. code .. " end")
> Now, each time you call 'f', the first argument is the environment where
> the code will run. (Of course, if the original code uses the vararg, it
> should be corrected to slip this extra first argument.)

That on the other side looks horribly un-lua-like to me (and unefficient
if the code in question is long enough), also this wont work for loadfile().
Concat some code before and after a string to change it looks so hackish :/