-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Introduce empty Ranges #201
Conversation
I see in one of your commits since I first left comments that you added the following:
I think that statement should be the core of your argument. That's an excellent point that is "entirely about Pony" that would justify a breaking change. Given you didnt find much code using this, you can't make a good "its easy to create bugs" based on empirical evidence But, you should be able to show code that the average reader of the RFC would expect to do one thing and you can show that it doesnt do that. If you can demonstrate that, and show that there aren't surprising corner cases with the changes you propose, then I think it would be a change I could support wholeheartedly. |
Given that performance is immediately after correctness in the Pony principles, it would be good to note if there are performance implications of the RFC changes. |
This needs some more preparation time. I will reopen when I have a significantly improved version |
@SeanTAllen I agree - having a default Yes, I am afraid this would be a very breaking change... |
@stefandd I think that is reasonable break. The current default is, I think, downright awful. Really really bad. I think this is a good breakage. A giant PITA breakage but it removes a serious issue with the API that you pointed out. I think that not having any default would be a good thing here as well. |
I think the other thing that could be argued from this, if we don't want the breaking change is that Range shouldn't support negative decrementing and that should be the sole domain of an updated Reverse. You are perhaps unintentionally bringing me around to that point of view @stefandd. |
Yes, that is why I felt it was important to point out the type assymetry, no matter what the final conclusion for this RFC will be. Also it is a good discussion to have... |
I am on the side of having a |
I dont think it is convenience. I think the combination of API and that default choice is error prone. And "dont create error prone defaults" is a principle of mine. |
Ok, so thinking about this. I think @stefandd / @rhagenson is something like this.
Except... well that doesn't work for floats. I can't use ISize with a Float that I want to increment by a non-integer value. I dont offhand know how do support for integer types and floating point types without also having the foot guns except by having 2 different Range and Reverse implementations or... by having lots of runtime errors if you set things up poorly. I'm very open to hearing ideas on how to address and if it is possible to remove the footguns or if the best we can do is have ISize rather than USize as the default. So after looking at
|
Another oddity of |
I think the error prone default you had in mind is the one Stefan showed where, since the default parameter is USize, a -2 in effect is really adding USize.max_value()-2. Right? If so, that was not what I was thinking about for the major error we were intending to solve. I was working from the idea of the type parameter determines the range of values that are possible and the method determines the direction. So if I want to have a range that includes signed integers I need an ISize, but if I only want positives then I want USize. I then assume the latter is more common based on how I have seen Range being used. |
Right but having documentation that says "USE NEGATIVE VALUES, its cool" and a default parameter that makes that negative value actually an integer underflow is just an awful confluence of items. We can't in good conscience drop Reverse if that is the API we are giving folks. |
Absolutely. I will have to sit down later today and collect my thoughts on the API that is "best" in my opinion. Not to get too far away from the original point of this RFC any change must include the empty ranges as that was fixing one possible footgun in the existing API. |
I think we should entertain getting away from the RFC. If this RFC is impetus for something different than it is right now, I think that is ok. I also think that we could say, we are ok with this RFC "just as it is" and we approve it and then ask @stefandd or something else to tackle the "larger issues" we are addressing now. |
What about, like initially suggested by @stefandd, having the following signature: Range[A: (Real[A] val & Number) = USize] is Iterator[A]
new create(from: A, to: A, inc: A = 1, backward: Bool = false) Advantages
There's still a question though about the interval of the ranges' values: is it closed or open? If it is open, counting down from 10 to 1 with |
@ponylang/committer @stefandd @pmetras I do not see a clear consensus on a direction for unifying |
I agree that the RFP as it is solves a first problem. We can open another one later to decide about |
My suggestion for resolving the
|
On the sync call we discussed that we want to leave the We will vote on this during next week's sync call, unless the RFC author wants to make any further changes between now and then, or delay the vote based on feedback. |
I assume that acceptance of this RFP will invalidate this one: added range_redesign rfc. |
This was accepted at the sync meeting. We still would like to see another RFC to address Reverse and various other issues. |
RE: additional RFC for Reverse and Range, I've opened an "official" issue for that: #204 |
No description provided.