#12978: conditionally_defined decorator for methods and nested classes
-------------------------------------------------+-------------------------
Reporter: nthiery | Owner: jason
Type: enhancement | Status: new
Priority: major | Milestone: sage-
Component: misc | wishlist
Keywords: categories, | Resolution:
conditionally_defined | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------------------------+-------------------------
Comment (by nthiery):
Hi Simon!
Replying to [comment:1 SimonKing]:
> What do you want to happen, if the condition in "conditionally_defined"
is not met? Raise an attribute error (probably yes)?
I want the same behavior as for a lazy attribute when the value is
NotImplemented: in that case, the lookup proceeds in the super class
hierarchy. And of course if it's not found there we get an
AttributeError.
> Wouldn't it be nice to have ''several'' implementations of a method,
> and choose one of them according to certain parameters?
This indeed sounds like a natural feature, but I don't have a strong
use case yet for it. In all the examples I have in my mind, the
"other" implementations are provided by the super classes. So I would
focus on the decorator for the simple ``conditionally_defined'' case first
and gather
experience on its use before thinking about a good syntax for
``several implementations''; it might at then end be just simpler and more
explicit to stick to doing this manually with a lazy attribute as in your
example above.
Cheers,
Nicolas
--
Ticket URL: <http://trac.sagemath.org/ticket/12978#comment:2>
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/groups/opt_out.