[PEAK] 'Categories' in Python
Andy Gross
andy at andygross.org
Fri Dec 10 18:21:05 EST 2004
> Your implementation is backwards. Categories are added to existing
> classes without their consent. Don't call what you're doing
> categories.
You're right, I was reading the Objective-C specs wrong. However, the
specific use case I have requires the consent of the class. It needs
to define 'categories' - methods that typically operate on one two data
members of the class. Can you think of a better name, or a better way
to think about this?
> Also, it's not really useful to distinguish between methods that a
> class originally had, and the methods they acquired from a category.
Maybe not enough to warrant an extra decorator, but if you wanted to
define rules for resolving name conflicts between category methods and
normal methods, it might be helpful. Point taken, though.
>
> This is an implementation of Category that works in Objective-C terms:
That looks a lot nicer! (this is my first real metaclass exercise).
But I'd like a general facility for classes to define categories (or
whatever they should be called) under which they can be extended. A
mechanism that could encompass both concepts with an appropriate name
would be ideal. Mulling it over...
/arg
More information about the PEAK
mailing list