On Thu, Sep 19, 2013 at 9:48 AM, Peter Bruin <pjbr...@gmail.com> wrote:
> I don't think I said that I wanted more static inheritance.
>
>
>> Basically, you want
>>
>>     class IntegralDomainElement(Element):
>>         ...
>>
>>     class IntegralDomain(Parent):
>>         ...
>>
>>     class EuclideanDomainElement(IntegralDomainElement):
>>         def xgcd(self, other):
>>             ...
>>
>>     class EuclideanDomain(IntegralDomain):
>>        Element = EuclideanDomainElement
>>
>>     class EuclideanDomains(IntegralDomains):
>>         ParentMethods = EuclideanDomain
>>
>> instead of
>>
>>     class EuclideanDomainElement:
>>         def xgcd(self, other):
>>             ...
>>
>>     class EuclideanDomain:
>>         ...
>>
>>     class EuclideanDomains(IntegralDomains):
>>         ElementMethods = EuclideanDomainElement
>>         ParentMethods = EuclideanDomain
>
>
> No, I want
>
> class IntegralDomainElement(Element):
> ...
>
> class IntegralDomain(Parent):
> Element = IntegralDomainElement
>>
>> class EuclideanDomainElement(Element):
>> def xgcd(self, other):
>> ...
>> class EuclideanDomain(Parent):
>> Element = EuclideanDomainElement
>
> class IntegralDomains(Category_singleton):
> ParentMethods = IntegralDomain
>
> class EuclideanDomains(Category_singleton):
> ParentMethods = EuclideanDomain
>
> def super_categories(self):
> return [IntegralDomains()]

So you don't actually want the long inheritance as seen in
https://github.com/sagemath/sage/blob/8118b2b39e3a129a5a6186fdc9917940f92b87a6/src/sage/structure/element.pyx#L2773

> I would expect the category framework to figure out that if R is an object
> in EuclideanDomains, then R.element_class should dynamically inherit from
> both EuclideanDomainElement and IntegralDomainElement.

It already does. R need not descend from EuclideanDomain, it simply
declares its category as EuclideanDomains.

The difference between your proposal and what currently exists are

(1) The Element[Methods] class is attached to the category's
ParentMethods, rather than the category itself and
(2) The Element and Object method classes are required to inherit from
Element and Parent directly. I don't see what value this adds, as the
concrete R.element_class values will already have this property.

> Less importantly, I would also prefer ParentMethods to be called Object,
> ObjectClass or something similar, both because objects needn't be parents
> and because the class in question could have other attributes that are not
> methods.

Yeah. Unfortunately, we have object and SageObject that mean entirely
different things. There is also CategoryObject which is a superclass
of Parent (=Object in the category of Sets). Element doesn't actually
makes sense on CategoryObject.

- Robert

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to