lua-users home
lua-l archive

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


On Fri, Jun 26, 2015 at 9:39 PM, Tim Hill <drtimhill@gmail.com> wrote:
>
>> 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
>
>
>

It is an interesting point. I've more than a few times wished some C
API functionality were exposed to Lua code. (Or vice-versa. I mean,
sure I can look up the global string, then the field gsub, and push
everything and call it, but it seems like it'd be so much more
efficient if I could just call directly into the internal function
that does the string.gsub logic.)

Ultimately I feel like Lua's popularity has led to it being used by a
lot of people, for a lot of things it was never really designed for.
It's designed to be embedded in an application for high-level control
logic, not to have the entire application written in it. Still it's a
fantastic language and you *can* write entire applications in it with
a few libraries, but it lacks some features you'd expect from a
language intended for writing applications in, because it isn't one.

-- 
Sent from my Game Boy.