On Tue, Sep 24, 2013 at 9:02 AM, Simon King <simon.k...@uni-jena.de> wrote:
> Hi Peter,
>
> On 2013-09-24, Peter Bruin <pjbr...@gmail.com> wrote:
>> We already have FieldElement, which is a Cython class consisting of
>> methods, including is_unit().  Ignoring my opinion about C.ElementMethods
>> for a moment, why not just move the existing methods in
>> FieldsElementMethods to FieldElement and then set Fields.ElementMethods =
>> FieldElement, and similarly for other Element classes?  (With or without
>> static inheritance between the Cython classes, whichever makes it work.)
>
> According to my earlier posts: I of course believe that this would make sense.
>
> Perhaps Nicolas reads this and can comment: What reason has there been to not
> derive Fields.ElementMethods from FieldElement?

The reason to not let Rings.ElementMethods derive from RingElement is
that then matrices (once they derive from ModuleElement) could not
derive from it safely (the diamond problem below). The same logic
could apply to FieldElement but I don't have an example off-hand.

I also think we should get rid of the (existing) cdef FieldElement,
EuclideanDomainElement, etc. as they are deceptively *not*
superclasses of all field elements, euclidean domain elements, etc.
(and for the reasons discussed on this thread can't be).

sage: isinstance(GF(5)(1), FieldElement)
False
sage: isinstance(QQ['x'], EuclideanDomainElement)
False

Now we could let FieldElement = Fields.ElementMethods instead.

> Of course, surprises may happen when one runs the doc tests. I remember
> one "funny" issue: I wanted to create a Python class simultaneously
> inheriting from the two Cython classes RingElement and Morphism. But it
> led to doctest errors. If I understood correctly the Cython developers
> agreed that this was a bug in Cython: It confused cdef public attributes
> of the two base classes.

Yeah, and I'm still not sure how to detect this conflict at runtime in
Python when the bad derived class is created.

- 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