[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: OO library w/ functions to create classes? (Re: syntaxic shugar proposition : generic do block)
- From: Sam Roberts <sroberts@...>
- Date: Wed, 29 Nov 2006 10:54:01 -0800
On Wed, Nov 29, 2006 at 11:26:00AM +0100, Mildred wrote:
> So, actually, I created a class thunction that takes a function as
> argument, change the environment of the function (then defined slots
> would go in that environment table), and then run the function to
> populate the environment (the class). Actually the syntax is :
> myclass = class(function()
> slot = val
> function slot(self, ...)
I'd be very, very interested in seeing this. There are lots of "its easy
to do OO in lua" code scraps around, but searching luaforge and the wiki
last night, I couldn't find any examples of them packaged up into a
reusable library of class factory functions, and particularly not that
use the setfenv() trick so that explicit self references aren't always
Does anybody have any links to such an OO library?
I don't need inheritance, but I am looking for a pure-lua solution
(i.e., not token filter or compiler hacks).
Also, if it included examples of how to build behaviourly identical
"classes" from C based on user-data, particularly ones that are
"extensible", that would sure be nice...
"extensible" - I mean that I can add/replace methods of the class at
run-time, and that I can also add/replace methods on specific instances
of the class at run-time.