Lua
                ~     ~




2010   1   23
Name:
                    Isoparametric
                               Blog:


                http://d.hatena.ne.jp/Isopa...
by Python




2010   1   23
Lua
                                                  Lua                                        TeCGraf


               ...
Lua
                                                    Lua                                           TeCGraf


          ...
1993
                Tecgraf

                Tecgraf



                Lua




                C -> Lua -> C


2010   1 ...
Python




2010   1   23
Python                 LL
           C
                      C
                 LL




           ANCI C
           C
    ...
2010   1   23
Lua



                Lua

                Lua

                Lua

                Lua

                Lua

          ...
Lua

                http://www.schulze-mueller.de/download/lua-poster-090207.pdf




2010   1   23
Lua

                http://www.schulze-mueller.de/download/lua-poster-090207.pdf




2010   1   23
byPython




2010   1   23
2010   1   23
2010   1   23
2010   1   23
2010   1   23
Web



                      Adobe's Photoshop Lightroom
                                    Ginga middleware
            ...
2010   1   23
2010   1   23
Perl Ruby



                                Python
                                  Lua

                       Python

...
Py(ry


                Py(ry 2.6: and as assert break class continue
                def del elif else except exec finally...
Lua

                     VM
                VM




                     GC


2010   1   23
JavaVM .NET       VM
                             VM

                Perl6

                Lua
                        V...
Lua

                Lua

                Lua C




2010   1   23
Lua




2010   1   23
……
                print(“Hello World”)
                % lua hello.lua




2010   1   23
--
                function fact (n)
                   if n == 0 then
                       return 1
                   ...
2010   1   23
2010   1   23
--




2010   1   23
--
                --[[


                ]]




2010   1   23
--     --[[
                       print("Hello!!")
                --[[
                       --]]
                     ...
--         --[[
                                               print("Hello!!")
                                    --[[
 ...
nil
                      number
                          boolean
                        string
                        ...
nil

                nil                 nil


                      ==nil
                      GC


                    ...
nil   false
                0                 true
2010   1   23
Patch   ……
                float   long
2010   1   23
“            ” ‘      ’ --
                      Lua




                0




                            immutable
2010 ...
..


                a = "1" + "1"                    2
                        b = "a" + "b"
                            ...
Lua




2010   1   23
==




2010   1   23
Lua



2010   1   23
1
                0
                    #




2010   1   23
1
                0
                    #




2010   1   23
Lua
                         key       value
                         “x”        9.2
                         nil

       ...
Lua       C
                      C

2010   1   23
nil




                ...



2010   1   23
C
                Lua




2010   1   23
local         do~end
                    Lua


                                 local




                do -- do~end
   ...
+         -       *       /
            ^         %           -



            < > <= >= == ~=




            and or not
...
if   while repeat   for




2010   1   23
if



2010   1   23
if op == “+” then
                    r=a+b
                                                 if
                elseif op ...
while



2010   1   23
while
                local i = 1
                while t[i] do
                    print(t[i])
                    i=i+1
...
repeat



2010   1   23
repeat
            --
            repeat
                line = io.read()
            untile line ~= “”
            print(...
for



2010   1   23
--            for
           for i=10,1,-1 do --                    for
              print(i)
           end

           ...
break     return

                switch

                continue

                         break     return


          ...
2010   1   23
2010   1   23
(co-routine)




2010   1   23
2010   1   23
2010   1   23
co-




2010   1   23
co-routine




2010   1   23
2010   1   23
……     CAPI




                coroutine.create
                coroutine.resume
                coroutine.running
      ...
coroutine.status


                suspended


                running


                dead


                normal

20...
co = coroutine.create(
                function ()
                    print("start")
                    coroutine.yield(...
co = coroutine.create(
                                               function ()
            co = coroutine.create(
     ...
croutine.create


                croutine.resume


                croutine.yield




2010   1   23
1
                     1   1



                ……




2010   1   23
C Lua




2010   1   23
Lua




                C         Lua
2010   1   23
C Lua




                C           Lua
2010   1   23
Lua C




                C       Lua
2010   1   23
Lua C




                C       Lua
2010   1   23
Lua




                C         Lua
2010   1   23
Lua




                          20


                      C
2010   1   23
2010   1   23
malloc/free/realloc




2010   1   23
KByte

                C
                    →




                    LTR (Lua Tiny RAM) Patch



2010   1   23
dlmalloc



2010   1   23
tolua++   luabind

                tolua++             Lua



                C++

2010   1   23
printf




                Windows




2010   1   23
2010   1   23
2010   1   23
C                         Lua
                C     Lua



                        t = lua_newthread(L);



              ...
GC
                          GC
                GC




                     GC




2010   1   23
__add, __sub, __mul, __div, __unm
                      ,__mod   ,__pow

                               __eq          ,__l...
mt = {}
       mt.__add = function (lhs, rhs)
          print(lhs, rhs, "mt._add")
          return lhs
       end
       ...
Lua




                            __mode   ”k”
                      ”v”




2010   1   23
weak = {}
                mt = {__mode="k"} --
                setmetatable(weak,mt) --
                key = {} --
      ...
_G

                a = “b” _G[“a”] = “b”

                                a[“b”]   a.b

                     _G



2010  ...
t:hoge()   t.hoge(t)




2010   1   23
Hoge = {value = 0}
                function Hoge:new(c)        h:setValue(100)
                   c = c or {}
            ...
2010   1   23
I/O

                OS



2010   1   23
Lua
                                  Lua 5.1.4 (2008-8-22)

                              Lua 5.2 (work2) (2010-1-13)

  ...
Lua




2010   1   23
2010   1   23
Upcoming SlideShare
Loading in...5
×

最速の言語Lua ~Python Hack-a-thon #3~

15,721

Published on

Python Hack-a-thon #3でLuaについて発表したときの資料です

Published in: Technology
0 Comments
20 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
15,721
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
56
Comments
0
Likes
20
Embeds 0
No embeds

No notes for slide
  • 最速の言語Lua ~Python Hack-a-thon #3~

    1. 1. Lua ~ ~ 2010 1 23
    2. 2. Name: Isoparametric Blog: http://d.hatena.ne.jp/Isoparametric/ 2010 1 23
    3. 3. by Python 2010 1 23
    4. 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. 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. 6. 1993 Tecgraf Tecgraf Lua C -> Lua -> C 2010 1 23
    7. 7. Python 2010 1 23
    8. 8. Python LL C C LL ANCI C C GC JavaScript prototype Lua 2010 1 23
    9. 9. 2010 1 23
    10. 10. Lua Lua Lua Lua Lua Lua Lua MIT license 2010 1 23
    11. 11. Lua http://www.schulze-mueller.de/download/lua-poster-090207.pdf 2010 1 23
    12. 12. Lua http://www.schulze-mueller.de/download/lua-poster-090207.pdf 2010 1 23
    13. 13. byPython 2010 1 23
    14. 14. 2010 1 23
    15. 15. 2010 1 23
    16. 16. 2010 1 23
    17. 17. 2010 1 23
    18. 18. Web Adobe's Photoshop Lightroom Ginga middleware World of Warcraft 2010 1 23
    19. 19. 2010 1 23
    20. 20. 2010 1 23
    21. 21. Perl Ruby Python Lua Python Maya Inkscape Python Lua 2010 1 23
    22. 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
    23. 23. Lua VM VM GC 2010 1 23
    24. 24. JavaVM .NET VM VM Perl6 Lua VM 2010 1 23
    25. 25. Lua Lua Lua C 2010 1 23
    26. 26. Lua 2010 1 23
    27. 27. …… print(“Hello World”) % lua hello.lua 2010 1 23
    28. 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
    29. 29. 2010 1 23
    30. 30. 2010 1 23
    31. 31. -- 2010 1 23
    32. 32. -- --[[ ]] 2010 1 23
    33. 33. -- --[[ print("Hello!!") --[[ --]] ↓ ]] ----[[ print("Hello!!") --]] 2010 1 23
    34. 34. -- --[[ print("Hello!!") --[[ --]] ↓ ]] ----[[ print("Hello!!") --]] --[=[ ... ]=] [[ ]] = [[ ]] 2010 1 23
    35. 35. nil number boolean string table function userdata thread 2010 1 23
    36. 36. nil nil nil ==nil GC nil 2010 1 23
    37. 37. nil false 0 true 2010 1 23
    38. 38. Patch …… float long 2010 1 23
    39. 39. “ ” ‘ ’ -- Lua 0 immutable 2010 1 23
    40. 40. .. a = "1" + "1" 2 b = "a" + "b" b = “a” .. “b” 2010 1 23
    41. 41. Lua 2010 1 23
    42. 42. == 2010 1 23
    43. 43. Lua 2010 1 23
    44. 44. 1 0 # 2010 1 23
    45. 45. 1 0 # 2010 1 23
    46. 46. Lua key value “x” 9.2 nil Header value 100 200 1 300 nil 2010 1 23
    47. 47. Lua C C 2010 1 23
    48. 48. nil ... 2010 1 23
    49. 49. C Lua 2010 1 23
    50. 50. local do~end Lua local do -- do~end local a = 1 print(a) -- end print(a) -- 2010 1 23
    51. 51. + - * / ^ % - < > <= >= == ~= and or not 2010 1 23
    52. 52. if while repeat for 2010 1 23
    53. 53. if 2010 1 23
    54. 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
    55. 55. while 2010 1 23
    56. 56. while local i = 1 while t[i] do print(t[i]) i=i+1 end 2010 1 23
    57. 57. repeat 2010 1 23
    58. 58. repeat -- repeat line = io.read() untile line ~= “” print(line) -- local local sqr = x/2 repeat sqr = (sqr + x/sqr)/2 local err = math.abs(sqr^2 - x) untile err < x/10000 -- err 2010 1 23
    59. 59. for 2010 1 23
    60. 60. -- for for i=10,1,-1 do -- for print(i) end -- for for i,v in ipairs(array) do print(v) end -- for ipairs 2010 1 23
    61. 61. break return switch continue break return continue Patch 5.2 2010 1 23
    62. 62. 2010 1 23
    63. 63. 2010 1 23
    64. 64. (co-routine) 2010 1 23
    65. 65. 2010 1 23
    66. 66. 2010 1 23
    67. 67. co- 2010 1 23
    68. 68. co-routine 2010 1 23
    69. 69. 2010 1 23
    70. 70. …… CAPI coroutine.create coroutine.resume coroutine.running coroutine.status coroutine.wrap coroutine.yield Lua 2010 1 23
    71. 71. coroutine.status suspended running dead normal 2010 1 23
    72. 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. 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
    74. 74. croutine.create croutine.resume croutine.yield 2010 1 23
    75. 75. 1 1 1 …… 2010 1 23
    76. 76. C Lua 2010 1 23
    77. 77. Lua C Lua 2010 1 23
    78. 78. C Lua C Lua 2010 1 23
    79. 79. Lua C C Lua 2010 1 23
    80. 80. Lua C C Lua 2010 1 23
    81. 81. Lua C Lua 2010 1 23
    82. 82. Lua 20 C 2010 1 23
    83. 83. 2010 1 23
    84. 84. malloc/free/realloc 2010 1 23
    85. 85. KByte C → LTR (Lua Tiny RAM) Patch 2010 1 23
    86. 86. dlmalloc 2010 1 23
    87. 87. tolua++ luabind tolua++ Lua C++ 2010 1 23
    88. 88. printf Windows 2010 1 23
    89. 89. 2010 1 23
    90. 90. 2010 1 23
    91. 91. C Lua C Lua t = lua_newthread(L); GC Lua GC 2010 1 23
    92. 92. GC GC GC GC 2010 1 23
    93. 93. __add, __sub, __mul, __div, __unm ,__mod ,__pow __eq ,__lt ,__le tostring __tostring __index __newindex 2010 1 23
    94. 94. mt = {} mt.__add = function (lhs, rhs) print(lhs, rhs, "mt._add") return lhs end hoge = {} foo = {} setmetatable(hoge, mt) -- hoge = hoge + foo -- 2010 1 23
    95. 95. Lua __mode ”k” ”v” 2010 1 23
    96. 96. weak = {} mt = {__mode="k"} -- setmetatable(weak,mt) -- key = {} -- weak[key] = 1 key = {} -- weak[key] = 2 -- collectgarbage() -- for k, v in pairs(weak) do print(v) end --> 2 2010 1 23
    97. 97. _G a = “b” _G[“a”] = “b” a[“b”] a.b _G 2010 1 23
    98. 98. t:hoge() t.hoge(t) 2010 1 23
    99. 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
    100. 100. 2010 1 23
    101. 101. I/O OS 2010 1 23
    102. 102. Lua Lua 5.1.4 (2008-8-22) Lua 5.2 (work2) (2010-1-13) 5.2 Lua! Patch …… 2010 1 23
    103. 103. Lua 2010 1 23
    104. 104. 2010 1 23
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×