Age | Commit message (Collapse) | Author | |
---|---|---|---|
2024-06-11 | Allow Python-like 'object = ClassName(ctor args)' constructor calls. | Nat Goodspeed | |
The discussions we've read about Lua classes conventionally use ClassName:new() as the constructor, and so far we've followed that convention. But setting metaclass(ClassName).__call = ClassName.new permits Lua to respond to calls of the form ClassName(ctor args) by implicitly calling ClassName:new(ctor args). Introduce util.classctor(). Calling util.classctor(ClassName) sets ClassName's metaclass's __call to ClassName's constructor method. If the constructor method is named something other than new(), pass ClassName.method as the second arg. Use util.classctor() on each of our classes that defines a new() method. Replace ClassName:new(args) calls with ClassName(args) calls throughout. | |||
2024-03-25 | util.lua claims functions are in alpha order - make it so. | Nat Goodspeed | |
Also streamline util.contains(), given table.find(). | |||
2024-03-21 | Accept an array for "add_list_item" and change EVENT_LIST type | Mnikolenko Productengine | |
2024-03-13 | util.join() is unnecessary: luau provides table.concat(). | Nat Goodspeed | |
2024-03-11 | Lua already has a conventional cheap test for empty table. | Nat Goodspeed | |
2024-03-07 | Finish WaitQueue, ErrorQueue; add util.count(), join(); extend qtest. | Nat Goodspeed | |
For WaitQueue, nail down the mechanism for declaring a subclass and for calling a base-class method from a subclass override. Break out new _wake_waiters() method from Enqueue(): we need to do the same from close(), in case there are waiting consumers. Also, in Lua, 0 is not false. Instead of bundling a normal/error flag with every queued value, make ErrorQueue overload its _closed attribute. Once you call ErrorQueue:Error(), every subsequent Dequeue() call by any consumer will re-raise the same error. util.count() literally counts entries in a table, since #t is documented to be unreliable. (If you create a list with 5 entries and delete the middle one, #t might return 2 or it might return 5, but it won't return 4.) util.join() fixes a curious omission from Luau's string library: like Python's str.join(), it concatenates all the strings from a list with an optional separator. We assume that incrementally building a list of strings and then doing a single allocation for the desired result string is cheaper than reallocating each of a sequence of partial concatenated results. Add qtest test that posts individual items to a WaitQueue, waking waiting consumers to retrieve the next available result. Add test proving that calling ErrorQueue:Error() propagates the error to all consumers. |