Re: [sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-24 Thread Nicolas M. Thiery
On Mon, Apr 23, 2012 at 05:48:10AM -0700, Simon King wrote: ... Our current metaclasses all work by overriding a magical method of type, or adding a magical method to type. Ideally, this should be in a customisable way. In some cases, we want to override not just one method. Currently, each

Re: [sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-24 Thread Nicolas M. Thiery
On Mon, Apr 23, 2012 at 05:59:04AM -0700, Simon King wrote: In CustomisationMetaclass, it should not be needed to explicitly state which methods are to be customised. Instead, CustomisationMetaclass should look if it finds a method named __classbla__ and would *automatically* customize

[sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-24 Thread Simon King
Hi Nicolas! On 2012-04-24, Nicolas M. Thiery nicolas.thi...@u-psud.fr wrote: On Mon, Apr 23, 2012 at 05:59:04AM -0700, Simon King wrote: Hence, class MyClass(Parent): __metaclass__ = CustomisationMetaclass @staticmethod def __classadd__(... should suffice. I like

Re: [sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-24 Thread Nicolas M. Thiery
On Tue, Apr 24, 2012 at 07:23:27PM +, Simon King wrote: OK. But I think priority should be given to cythonization of the existing metaclasses. Namely, Florent found out how one can produce a cdef'd metaclasses, so that its instances (thus, usual classes) inherit the fast methods (like

[sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-23 Thread Simon King
Hi Nicolas, On 22 Apr., 00:37, Nicolas M. Thiery nicolas.thi...@u-psud.fr wrote: So the question is how many metaclasses we forsee in the future. Some ideas are below. NestedClassMetaclass is really a workaround for a mishandling of nested classes by Python; Abstractly: What

[sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-23 Thread Simon King
PS: On 23 Apr., 14:48, Simon King simon.k...@uni-jena.de wrote: class MyClass(Parent):     __metaclass__ = CustomisationMetaclass(call,init,add) ...     @staticmethod     def __classadd__(cls, other):         if cls is other:             return cls         return

Re: [sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-22 Thread Nicolas M. Thiery
On Sat, Apr 21, 2012 at 02:41:26PM +, Simon King wrote: But one could argue that explicit is better than implicit. If we just see a finite number of applications, then explicitly programming these finitely many instances may be easier to understand than a general framework for an infinity

[sage-combinat-devel] Re: Do we want a metaclass framework?

2012-04-21 Thread Simon King
Hi Nicolas, On 2012-04-21, Nicolas M. Thiery nicolas.thi...@u-psud.fr wrote: At the same time, it's getting far enough from the KISS principle to get me uncomfortable. Isn't the use of meta-meta classes overkill (and thus potentially fragile, if we are not sure of a Python/Cython rock solid