lua-users home
lua-l archive

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


> On Jun 26, 2015, at 6:22 PM, Soni L. <fakedme@gmail.com> wrote:
> 
>>   Then wrap Lua up into a module:
>> 
>> 	lua = require "lua"
>> 
>> 	L = lua.Lnewstate()
>> 	L:gc('stop')
>> 	L:Lopenlibs()
>> 	L:gc('start')
> But that looks nothing like Lua!
> 
>> 

Sure looks like Lua to me.

>> 	...
>> 
>>   -spc (Or instead of the entirety of Lua, just enough to sandbox like you
>> 	can in C ... )
>> 
> Lua is a programming language. You should be able to use it to its fullest extent from itself. You don't need to use assembly to be able to use all of C's features: you can use all of C's features from C itself. Same goes for Java (altho Scala is more powerful), and many other languages. Why should it be different with Lua?

But you’re not talking about using all of Lua’s features, you’re talking about EXTENDING Lua .. and to extend C you very well MIGHT need to code up some assembly language (or, worse, change the compiler).

Lua has a clearly defined state model. You want to change that state model to support sandboxing in a very specific way. As has been shown, that can be done with a new library that projects the Lua C API into Lua itself. What’s wrong with that? As for what that API looks like, well that’s just a matter of abstraction. For example, it’s pretty easy to code this:

lua = require “lua”
f = function () … end
lua.execute(f)


—Tim