Releases: lua-stdlib/prototype
[ANN] std.prototype 1.0 released
I am happy to announce release 1.0 of std.prototype.
std.prototype's homepage is at https://github.com/lua-stdlib/prototype, with documentation at https://lua-stdlib.github.io/prototype.
This is a straight forward prototype-based object system, and a selection of useful objects build on it.
These modules started life in lua-stdlib. I’m in the process of slimming down lua-stdlib in preparation for the next release though, part of which means that you can now use std.prototype without requiring the installation of all of stdlib.
Install it with LuaRocks, using:
luarocks install std.prototype 1.0
Noteworthy changes in release 1.0 (2016-02-07) [stable]
New features (since lua-stdlib-41.2)
-
Initial release, now separated out from lua-stdlib.
-
Objects and Modules are no longer conflated - what you get back from a
require "prototype.something"is now ALWAYS a module:local object = require "std.prototype.object" assert (object.type (object) == "Module")
And the modules that provide objects have a new
prototypefield that contains the prototye for that kind of object:local Object = object.prototype assert (object.type (Object) == "Object")
For backwards compatibility, if you call the module with a constructor table, the previous recommended way to disambiguate between a module and the object it prototyped, that table is passed through to the module's object prototype.
-
Now that we have proper separation of concerns between module tables and object prototype tables, the central
std.prototype.object.mapfieldsinstantiation function is much cleaner and faster. -
We used to have an object module method,
std.object.type, which often got imported using:local prototype = require "std.object".type
So we renamed it to
std.object.prototypeto avoid a name clash with thetypesymbol, and subsequently deprecated the earlier equivalenttypemethod; but that was a mistake, because core Lua providestype, andio.type(and in recent releases,math.type). So now, for orthogonality with core Lua, we're going back to usingstd.prototype.object.type, because that just makes more sense. Sorry!
Bug fixes
- You can now derive other types from
std.prototype.setby passing a_typefield in the init argument, just like the other table argument objects. - In-order iteration with
__pairsmetamethod has been reinstated. There were no spec examples, and the implementation mysteriously went missing in a previous round of refactoring.
Incompatible changes
- Deprecated methods and functions have all been removed.
std.treeis nowstd.prototype.trieand defines a Trie object, no a Tree object. The implementation has been a Radix Tree (aka Trie) all along.- Objects no longer honor mangling and stripping
_functionstables from objects during instantiation, instead move your actual object into the moduleprototypefield, and add the module functions to the parent table returned when the module is required.