On Wed, Feb 19, 2014 at 08:11:26AM -0500, Mark Shimozono wrote:
> What if two classes coming from different categories 
> (neither inheriting from the other) share a method name,
> and both apply to the same instance?
> Which method would get invoked?
> (This is getting to the core of my admittedly nit-picky
> gripe about using method names to invoke category-based code).

That's a standard situation in object oriented programming when
multiple inheritance is involved. As Simon mentioned, Python resolves
this using a total order on the classes (called the mro). The outcome
might, or not, be what we want. In principle the two methods are
supposed to have the same semantic, so which one is picked should not
matter too much. When we care, typically for performance reasons, the
ambiguity should be resolved explicitly in the subclass.

See the "On the order of super categories" section in the upcoming
version of the primer from #10963:

http://sage.math.washington.edu/home/nthiery/sage-6.0/src/doc/output/html/en/reference/categories/sage/categories/primer.html

Cheers,
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

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

Reply via email to