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 combination of customised methods requires to > write a new metaclass. But why not have just *one* metametaclass > "CustomisationMetaclass", such that > CustomisationMetaclass("init","get","reduce") returns a metaclass that > allows customisation of three methods?
An alternative would be to have a single metaclass, subclass of type, that adds hooks to enable at once all special methods for classes. Pros: - It's simple - It pushes toward eventually having all those hooks directly in type - It is similar to what happens for objects: all hooks are directly available; you just implement those that you need. Inconvenient: - If a class does not use a hook, does it still pay an overhead for the handling of this hook? For most hooks, that's irrelevant: if a class does not use the __classmul__ hook it won't use the syntax A*B either. But a couple of hooks like __classcall__, __classinit__ could slow basic usage. Cheers, Nicolas -- Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net> http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.