I ran into the following problem for elements of rings of integers: they 
inherit from FieldElement. That's a problem when, for instance you want to 
implement a method "canonical_associate" that tries to find a canonical 
representative modulo multiplication by units. For fields, such a thing is 
easily defined, but for rings of integers such a method isn't necessarily 
easy to implement. It's natural to implement this method on "FieldElement", 
but then elements of rings of integers inherit that method (and it does the 
wrong thing there!)

I'd be interested if someone has a coherent idea about how we can handle 
such issues. It seems to me we have a problem in our inheritance hierarchy. 
I suspect someone made this design decision (that superficially looks like 
an error) for a good reason and may have put some thought into how to 
easily work around the obvious draw-backs.

The following mro illustrates the problem:

sage: R.<x>=ZZ[]
sage: K.<a>=NumberField(x^3+x+1)
sage: OK=K.ring_of_integers()
sage: type(OK.0).mro()
[<class 
'sage.rings.number_field.number_field_element.OrderElement_absolute'>,
 <class 
'sage.rings.number_field.number_field_element.NumberFieldElement_absolute'>,
 <class 'sage.rings.number_field.number_field_element.NumberFieldElement'>,
 <class 
'sage.rings.number_field.number_field_element_base.NumberFieldElement_base'>,
 <class 'sage.structure.element.FieldElement'>,
 <class 'sage.structure.element.CommutativeRingElement'>,
 <class 'sage.structure.element.RingElement'>,
 <class 'sage.structure.element.ModuleElement'>,
 <class 'sage.structure.element.Element'>,
 <class 'sage.structure.sage_object.SageObject'>,
 <class 'object'>]

-- 
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 view this discussion visit 
https://groups.google.com/d/msgid/sage-devel/358676a7-0542-4a4d-992e-30be9e1bde8cn%40googlegroups.com.

Reply via email to