[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Class structures
- From: Daniel Silverstone <dsilvers@...>
- Date: Sat, 22 May 2004 10:11:21 +0100
Brennan Leathers wrote:
Checked out the class subpage. One suggestion I have from a quick read
is that I prefer
ctr = Counter.New() // well, really .new would be even better :)
I'm grateful for the comments.
What some people haven't noticed I think is that my system does *NOT* create
globals with the classes in by default. I deliberately did that to prevent
the possibility of polluting the namespace too much. However there is the
Factory function which a lot of people have not noticed. Allowing constructs
like this:
Class "foo" {
func = function(self,i) print(self,i) end
}
foo = Factory "foo";
foo1 = foo()
foo2 = foo()
Which So I was figuring that in instances like counters people might do:
Class "Counter" { ... }
Counter = Factory "Counter"
However I guess that having a .new feature would be good, so I have added a
.new() method to the "aranha.class" class.
So given an object 'foo' we can do:
foo2 = classof(foo).new();
Also, I have modified the Class() function so that if the class you specify
is concrete already, instead of throwing an error it will return the class
object for it; allowing constructs like:
Class "Counter" { ... }
Counter = Class "Counter";
ctr1 = Counter.new();
I'm still evolving the interface, so more comments would be appreciated.
Remember though that I am trying to retain a quintessentially Lua feel to
the class system. The way that I have chosen to implement it gives us all
these funky ways of doing things (like getting hold of factory functions
and/or class objects etc)
Thanks,
Daniel
--
Daniel Silverstone http://www.digital-scurf.org/
PGP mail accepted and encouraged. Key Id: 2BC8 4016 2068 7895