On Thursday, January 23, 2014 2:25:36 AM UTC-8, Simon King wrote:

> And that's a general problem: 
> - I suppose generally one wishes to call __init__ of the base classes 
>   quite soon in a class' own __init__, so that useful attributes are 
>   correctly initialised. 
> - However, we want that the calls to __init_extra__ happen as late as 
>   possible, so that all data is available to execute the generic code. 
>

There is no general rule for when the __init__ of base classes should be 
called (if at all! It's quite legal in python to not do it, but then you'll 
have to be pretty sure about the implementation of the base class)

If you're *implementing* a class that mainly specifies an interface, it 
makes sense to call base.__init__ late, because you should make sure that 
everything is in place for the more generic code to work. That applies 
here, at least to some extent (certainly from the __init_extra__ 
perspective)

If you're *extending* a class (providing additional functionality) then you 
should probably call base.__init__ early, because you need the base class 
to have everything in order so that you use it in your extension work.

If you are both implementing and extending you should probably put the 
base.__init__ somewhere in the middle. It would be good in base.__init__ 
would document how functional it expects self to be when it is passed, 
though (i.e., which bits still need to be implemented). As you find here, 
one needs self.one() to work (or at least not segfault).

Another solution is setting the _no_base_coercion attribute on 
MPolynomial_generic. The generic __init_extra__ code fails anyway, so 
apparently the base ring coercion gets installed manually any way.

-- 
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