#18756: Use coerce actions in the category framework
-------------------------------------+-------------------------------------
Reporter: SimonKing | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.8
Component: coercion | Resolution:
Keywords: cython, coercion, | Merged in:
actions, categories | Reviewers: Travis Scrimshaw
Authors: Simon King | Work issues:
Report Upstream: N/A | Commit:
Branch: | fe7226d9e28d1dbf4130e8b57fb09885bd76226c
u/SimonKing/combinatorial_free_module_cython_coercion| Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by SimonKing):
Replying to [comment:31 nthiery]:
> However the above implementation is not uniform: we could imagine use
> cases where a category may want to implement such a `_get_action_`
> that occasionally returns `None`. Or a class `B` inheriting from `A`
> itself inheriting from `Parent`, where `B._get_action_` may want to
> return `None` to specify: use `A._get_action_`.
OK. But in the past, it has *never* been implemented to do this
automatically. It has never been the case that `Parent.get_action` went up
the MRO to test several `._get_action_` outputs until one of them returns
something interesting.
> So, to weight the pros and cons my questions are:
>
> - How invasive would it really be to move `Parent._get_action_` to
> `Sets.ParentMethods`? Does it actually requires to update anything
> else in the Sage code?
Yes. Everything that uses it in its cpdef form.
> - super calls would be the natural thing to do here. Alas super and
> categories don't work so well together. Still, could we find a
> reasonable enough syntax for this that we could advertise in the
> documentation of `_get_action_`.
Why "syntax"? If we would really want to go up the MRO/category hierarchy,
then we could in principle do so in `Parent.get_action`. I just don't know
if that makes much sense, but assume we have
{{{
class MyFirstParent(Parent):
def _get_action_(self, S,...):
return something when S is a ring
class MySecondParent(MyFirstParent):
def _get_action_(self, S,...):
return something when S is a field
}}}
We COULD make it so that `MySecondParent().get_action(S)` would
automatically first test the output of `MySecondParent._get_action_` and
then on `MyFirstParent._get_action_` --- there would be no special syntax
involved.
I only wonder if we WANT that to happen automatically.
> - Shall we investigate for a more uniform protocol where `get_action`
> would try each `_get_action_` method along the MRO until one returns
> something else than `None`?
I am not so sure. But it would be easy to implement (as I have explained
above).
--
Ticket URL: <http://trac.sagemath.org/ticket/18756#comment:32>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.