Re:Boot a linux kernel right inside your browser.
by dkersten on Wednesday May 18, 2011 @06:32AM
(#2559669)
Standard Lua may not have integer types, but as far as I know, LuaJIT does actually support integer types under the hood. At the very least, you can force it by declaring an integer using the FFI, eg:
local ffi = require("ffi")
int = ffi.new("int")
int = 10
print(int)
I also don't find the lack of macros in Lua as limiting as I do in other languages. For example, if I wanted to create an EDSL in Lua, I would have it parse a string at startup. For example, imagine a state machine DSL:
fsm = my_dsl[[
start: foo
stop: quux
foo -> bar
foo -> baz
bar -> foo
baz -> quux
]]{ foo = function()
code for foo here
end,
bar = function()
code for bar here
end,
baz = function()
code for baz here
end,
quux = function()
code for quux here
end
}
fsm.run()
As a real-world example, here is some Lua code I'm using in a hobby game project:
"That said, I'd give a higher priority for the language in my browser to be safe: some kind of correctness guarantee would be nice. Or even, while we're at it, some kind of way to analyze the script and say "this script GETS from urls x,y, and posts data d to z""
I definitely agree with the above.