3 ms·
While he is focusing on Javascript and only makes a passing reference to Lua, it's worth noting that it has a very flexible and efficient implementation of prop
by silentbicycle 18y ago
While he is focusing on Javascript and only makes a passing reference to Lua, it's worth noting that it has a very flexible and efficient implementation of property maps (called "tables") as its primary abstract data structure.
You can quite easily set up inheritance behavior for prototyping, along with read-only tables and several other things, by defining access hook functions in "metatables" (property tables for the tables themselves).
See also: Chapter 16 (OO) in _Programming in Lua_. The first edition is available online: http://www.lua.org/pil/16.2.html http://www.lua.org/pil/16.2.html
- jcromartie 18y agoIndeed. Lua lets you do practically anything you want, because it only gives you the building blocks of an object system.
- silentbicycle 18y agoIt's not an elaborate undertaking, either: you can make an object system in just under a page of code. Here's a good example, with lots of commentary: http://www.erix.it/progutil/gpeddler2/help/oo.html http://www.erix.it/progutil/gpeddler2/help/oo.html
- deleted 18y ago[deleted]
- nuclear_eclipse 18y agoI always find myself loving Lua, while continually wishing that it had a larger standard library like Python's. Without all the batteries included, it makes a great embeddable language, but stands very poorly on its own. It'd be my language of choice otherwise.
- deleted 18y ago[deleted]
- silentbicycle 18y agoSame here. Have you looked at LuaRocks, though? (http://www.luarocks.org/ http://www.luarocks.org/) It automatically grabs and installs packages, a la CPAN. It will take some time for there to be libraries for everything, of course, but the infrastructure is there.