[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: AKClassHierarchy
- From: Gavin Kistner <gavin@...>
- Date: Sun, 12 Feb 2006 11:00:17 -0700
On Feb 12, 2006, at 10:11 AM, PA wrote:
On Feb 12, 2006, at 14:05, Gavin Kistner wrote:
Which yet again points to the fact that 'super' type methods can't
be written using first-class functions in a way that allows them
to be used and re-shared. Pity.
Of course, they can... it just a question of how much you are
willing to pay for it.
To be clear, I mean the ability to do something like:
MyClass.prototype.doStuff = MyOtherClass.prototype.doStuff
If closures are used, the 'super' will be wrong in one of those. If a
hash associates the function object with a class, it will be wrong
for one of them.
But I suppose I contradicted myself later, for the use specifically
of wrapper functions that set up global variables or functions, while
possibly not thread-safe, might allow the above to work.
Hrm...unless I went crazy-stupid and used global variables and
wrapper functions. Something like...
If you are so inclined, you can define your class fully as a
closure. Check the PIL example under chapter 16.4 - Privacy:
As a language with first-class functions that are closures,
methods or protected methods (externally-accessible functions which
have access to private variables). As with JS, using the
'constructor' in this way causes each instance to have distinct
function instances for these methods. I probably don't need to tell
you, but the memory overhead, as well as the fact that these methods
are now 'locked in' for the instance, make this another interesting
way to twist the language that is usually ill-desired in application.