4. Lua
Lua TeCGraf
Lua
C
Lua VM
MIT License
Lua Lua
Pascal
Lua
Python Ruby Lua
Lua
Lua5.0 GC Lua5.1
GC Python
Ruby GC GC Lua
Lua C++ tolua++ Luabind
MIT License
2010 1 23
5. Lua
Lua TeCGraf
Lua
C
Lua VM
W
MIT License
Lua
iki Lua
pe
dia
Pascal
Lua
Python Ruby Lua
Lua
Lua5.0 GC Lua5.1
GC Python
Ruby GC GC Lua
Lua C++ tolua++ Luabind
MIT License
2010 1 23
6. 1993
Tecgraf
Tecgraf
Lua
C -> Lua -> C
2010 1 23
22. Py(ry
Py(ry 2.6: and as assert break class continue
def del elif else except exec finally for from
global if import in is lambda not or pass print
raise return try while with yield
Lua 5.1: and break do else elseif end false
for function if in local nil not or repeat
return then true until while
31 vs 21
2010 1 23
28. --
function fact (n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end
print("enter a number:")
a = io.read("*number")
print(fact(a))
2010 1 23
54. if op == “+” then
r=a+b
if
elseif op == “-” then
r=a-b
elseif op == “*” then
r=a*b
elseif op == “/” then
r=a/b
else
error(“invalid operation”)
end
2010 1 23
72. co = coroutine.create(
function ()
print("start")
coroutine.yield() --
print("resume")
end
)
-- co type thread
coroutine.resume(co) --
coroutine.resume(co) --
--> start
--> resume
2010 1 23
73. co = coroutine.create(
function ()
co = coroutine.create(
print("start")
function ()
local c = coroutine.create(
print("start")
function ()
coroutine.yield() --
print("nest coroutine start")
print("resume") coroutine.yield()
end print("nest coroutine resume")
) end
-- co type thread )
coroutine.resume(co) -- coroutine.resume(c)
coroutine.resume(c)
coroutine.resume(co) --
coroutine.yield()
print("resume")
end
--> start )
--> resume coroutine.resume(co) --
coroutine.resume(co) --
2010 1 23
99. Hoge = {value = 0}
function Hoge:new(c) h:setValue(100)
c = c or {}
setmetatable(c, self)
self.__index = self
h.setValue(h,100)
return c
end
function Hoge:setValue(v)
self.value = v
end
h = Hoge:new()
print(h.value)
h:setValue(100) h
print(h.value)
Hoge
--> 0
--> 100
2010 1 23