On 2015-11-23 14:24, Eric Gourgoulhon wrote:
Hi,
Le lundi 23 novembre 2015 10:55:40 UTC+1, Jeroen Demeyer a écrit :
Of course, you could argue that Element
should not have __add__ and __mul__ (since not all elements can be
added
or multiplied). But it doesn't really hurt to have them and raise
NotImplementedError (unless I'm missing something).
Maybe a too naive remark: what you propose seems against standard
object-oriented programming. Isn't it more clear to have a generic base
class Element and implement __add__ and __mul__ only in derived classes,
when relevant?
I get your point, but it's not black or white: we need to look at
advantages and disadvantages of having so many classes. One problem with
your "object-oriented programming" comment is that we cannot have
multiple inheritance for these classes, since they are extension types
(a.k.a. cdef classes). So we need to reimplement certain methods several
times. Then there is also some performance overhead of having all these
different classes.
The names are also confusing: isinstance(x, FieldElement) is *not* a
good way to check if x is in a field. We have the category framework for
that.
Jeroen.
--
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/d/optout.