Skip to content
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

String.find/String.rfind USize proposal #216

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hovsater
Copy link

@hovsater hovsater commented Dec 10, 2024

The current return type of String.find and String.rfind is ISize, which stems from its historical behavior of returning -1 when no match was found. However, the methods now return error for such cases. Returning USize makes more sense because indices are always non-negative, and it aligns with Array.find's method signature.

@ponylang-main ponylang-main added discuss during sync Should be discussed during an upcoming sync status - new The RFC is new and ready for discussion. labels Dec 10, 2024
Copy link
Member

@jemc jemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@chalcolith chalcolith added status - final comment period The RFC is finalized. Waiting for final comments. and removed status - new The RFC is new and ready for discussion. labels Dec 10, 2024
@SeanTAllen
Copy link
Member

@hovsater can you rebase this against main?

@hovsater
Copy link
Author

@hovsater can you rebase this against main?

Done!


# How We Teach This

N/A
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are teaching this in the same way we are currently teaching. Via the standard library documentation. This N/A should be changed. It is applicable and there is a means that we are already teaching such things.

Small change but important for not setting an incorrect precedent going forward.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be that we already teach the usage of rfind and find via the method documentation and that nothing needs to change regarding that. And that otherwise, inclusion in the release notes plus examples of how to update code where a type annotation is given and the lack of a change if type implication is used would suffice here.

We do however, I think want release notes that detail the change, that it is breaking and how to fix it if the break impacts on you. The fix in this case might be "obvious" but I think it behooves us to practice giving explanations for fixing any breaking changes we introduce.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. I've addressed that in 6746310.


# How We Test This

Standard CI and the compiler should identify most areas that need to be addressed. Additionally, any documentation, code examples, and guides should be reviewed and updated to reflect the new behavior.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a review should happen before this RFC is accepted as fixing anything that this breaks that isn't programmatically caught should be part of the acceptance criteria for merging the change to the return type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no usage in the tutorial that I can find.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no usage in pony-patterns that I can find.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only usage I can find on the website is a reference to this RFC from the most recent LWIP.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what should I write here instead, @SeanTAllen?


# Unresolved questions

N/A
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is applicable.

Can you change this to "none at this time". I believe that is what you meant.

However, given the state of this RFC, unresolved at this time is anything that needs to be updated that this might break in documentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought. Given that this will break existing code that might require changes in other ponylang org projects, I'd like to have encoded into this RFC or at least an agreement amongst committers that we will not merge this change without an assurance from the author of the PR that implements this to quickly address all breakages in ponylang org libraries that our nightly breakage tests identify (if any exist).

I've often been left to pick up that important piece and I'd like to have a discussion that about how we address that isn't solely "Sean labor".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is applicable.

Can you change this to "none at this time". I believe that is what you meant.

However, given the state of this RFC, unresolved at this time is anything that needs to be updated that this might break in documentation.

See 6746310.

@SeanTAllen
Copy link
Member

I'm in favor of this RFC with the changes I have requested.

@jemc
Copy link
Member

jemc commented Dec 17, 2024

The next few sync calls where we would vote on this are cancelled due to holidays, so we decided to approve this RFC today, conditional on Sean's concerns above being addressed to his satisfaction. So we don't need to wait for a future vote - this can get merged as soon as those changes have come in and been approved by Sean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss during sync Should be discussed during an upcoming sync status - final comment period The RFC is finalized. Waiting for final comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants