-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements a mantra for declaring abstract methods #6097
Comments
comment:1
This must be fixed by improving sageinspect. That should be easy.
|
Attachment: abstract_method-6097-nt.patch.gz |
comment:3
Replying to @williamstein:
I commented on those in the patch. |
This comment has been minimized.
This comment has been minimized.
comment:5
Making this fail on access is so introspection and command line unfriendly that I vote a very strong -1 to it. |
comment:6
Replying to @ncalexan:
Thanks for the feedback! Note that this is an exceptional situation: in principle, users are not supposed to encounter this situation Do you see any strong reason not to merge this patch as is, until we accumulate enough experience? |
Author: nthiery |
comment:7
Yes. One cannot even loop over attributes of an object generically with such behaviour! I really can't stress how bad an idea I think this is. |
comment:8
Replying to @ncalexan:
So what? The class of this object is broken in the first place. On the other hand, experience with MuPAD, tells that having early errors for such situations is much safer (note that a bound method need not be called immediately; instead it can be passed down to other functions and wreak havoc at a distant place later). My point is: the issue is non trivial enough that it requires more experience and further debate (not just the two of us). And we do not have the time for this right now. |
comment:9
Wait, what is the rush?
I think there is a significant difference between broken functionality and an object in the system that cannot be interrogated by the system.
This is often true. Can you guarantee that such a poisoned object can only be created by a user who "works hard" to do so? If that's the case then I remove whatever objections I have. |
comment:10
Replying to @ncalexan:
The category patches + followers depend on this. Total 22 patches = 1.3 Mb :-)
Fair enough.
In principle, such objects can only be created by:
I don't know how much "hard word" is the first point. The second point can only occur if:
Note that the category code includes checking methods that complains if a parent does not implement all the mandatory abstract methods. That being said, as a dev, I got caught myself at least once. So it's all a question of balance between two annoyances. |
comment:11
Why not make
These two can never be prevented against. So I'm more okay with this than I was. |
comment:12
Replying to @ncalexan:
Because abstract methods are perfectly valid in an abstract class. Actually, the user will want to use introspection to query for their doc, ...
|
comment:13
Replying to @nthiery:
This seems wrong to me. |
comment:14
Replying to @ncalexan:
Oh, sorry, I got completely confused. I though you were speaking about the Yes, adding an |
comment:15
Here is a second opinion. I really, really like the idea of adding such a decorator! And for the Here is a list of things that I don't like (most have been mentioned above):
None of these are strong reasons against inclusion, I guess, since it might be just a matter of opinion, or that I haven't thought enough about the subtleties. |
comment:16
Replying to @saliola:
I tried to advertise the feature to start such a discussion, but there was not much reaction. I think we first need to accumulate experience by using the current thing, and then discuss again. Release early, release often.
Thanks.
Thanks for the feedback! I am also not yet happy about the current state. Feel free to include those suggestions in the doc via a reviewers patch, so that users run into them in the future. |
comment:17
Hello, Replying to @nthiery:
I definitely missed this. I'm behind in reading the sage-devel emails.
You mentioned that in the doc and in the above comments, and I must admit
You can't really tell from what I wrote in my last comment, but I spent I thought about what I like and dislike about the existence of such a I wondered about, as ncalexan suggested, checking whether abstract methods I wondered about different mantras. If no error is returned on accessing
(The above currently doesn't work because I also wondered whether some methods might be decorated with Personally, I am leaning towards the idea of raising a So, lots of thoughts, not many conclusions. I decided to keep my last post short and to the point because I knew this
I think it isn't necessary since you have adequately stated in the |
comment:18
Though the interface hasn't completely settled, I think its stable enough to go in and worth starting to use. I'm opening a new ticket #6400 to review all the TODO's in this one. |
comment:19
Hi Franco! Replying to @saliola:
Oops, that was in my dreams. I only advertised it oraly at SD15. You should have been there :-)
:-)
Great.
Besides the nice visual effect, allowing for automatic checks is precisely the purpose of
That's sensible for Parents, but would not be reasonable for elements that could be created by the millions.
Note: you can do the same on x.class, which is what .test_not_implemented_methods does
I definitely would like this as well! Probably under a different name though, like
Ok. Let's see how this works in practice.
I did! Thanks very much for taking the time typing it up. Cheers, |
Merged: sage-4.1.alpha2 |
Reviewer: Robert Bradshaw |
Changed author from nthiery to Nicolas Thiéry |
Changed author from Nicolas Thiéry to Nicolas M. Thiéry |
This patch implements a decorator tha can be used to declare a method
that should be implemented by derived classes. This declaration should
typically include documentation for the specification for this method.
The purpose is to enforce a consistent and visual mantra for such
declarations. This is also used by #5891 for automated tests.
CC: @sagetrac-sage-combinat
Component: misc
Keywords: abstract methods
Author: Nicolas M. Thiéry
Reviewer: Robert Bradshaw
Merged: sage-4.1.alpha2
Issue created by migration from https://trac.sagemath.org/ticket/6097
The text was updated successfully, but these errors were encountered: