The design of Lua Language design, tutoriel programming in Lua document PDF.
Tables: problems
• the implementation of a concept with tables is not as good as a primitive implementation
• access control in objects
• length in sequences
• different implementations confound programmers
• DIY object systems
Coroutines
• old and well-established concept, but with several variations
• variations not equivalent
• several languages implement restricted forms of coroutines that are not equivalent to one-shot continuations
Coroutines in Lua
• first-class values
• in particular, we may invoke a coroutine from any point in a program
• stackful
• a coroutine can transfer control from inside any number of function calls
• asymmetrical
• different commands to resume and to yield
Coroutines in Lua
• simple and efficient implementation
• the easy part of multithreading
• first class + stackful = complete coroutines
• equivalent to one-shot continuations
• we can implement call/1cc
• coroutines present one-shot continuations in a format that is more
familiar to most programmers
…….
The design of Lua Language design (580 KO) (Cours PDF)