-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Rename String
.find_char
-> find
, rfind_char
-> rfind
, contains_char
-> contains
.
#100520
Conversation
…tains_char` -> `contains`.
38be04c
to
2372b12
Compare
This makes potentially exposing these functions to extensions and scripting impossible without breaking the ability to have both module and extension support, as scripting doesn't allow overloadeds It also nominally breaks compatibility but we don't guarantee module compatibility, but it's still very annoying for people making modules I'm also against this on the principle of readability, and it now makes It also breaks other planned additions, which are planned to be exposed, which would either have to not be exposed or be different from this |
This absolutely needs a proposal to track the discussion to not bother all reviewers etc. |
I appreciate the comment, and was hoping you would pop in, since you mentioned before you have reservations :).
I did not expect this many reservations about the change. Should I close this PR and make a proposal?
Is the reason that it's a hard rule to call in-engine functions the same as exposed functions? Because from a technical perspective, this would not be a problem.
True.
Can you elaborate what you mean by that?
Can you explain which exactly, and how this rename interferes with them? |
Yes because you can't use it in modules otherwise if you want to be able to use them as both a proper module and an extension, see
Why rename
The additions of |
So to summarise:
To me the suffix is helpful, most of the time we use a literal and then it doesn't matter, but it communicates intent and helps if it's a variable, where not having to go look for what that variable is is appreciated Edit: note to self that we should document some things about extensions and method bindings about this as a lot of people aren't aware about the ability to make code thats both a module and an extension and things to think about with that Edit 2: this is also a kind of change that's disruptive by causing hard to notice changes when merged for any PR that uses these methods, relying on people realising a PR needs a rebase to notice the renames fail CI |
If this is the only reason, it wouldn't be a hard limitation. It just means that the function is not exposed through the GDExtension API, and that modules designed to be used as both cannot use the
I was not aware they were called that because they are taking chars. In the spirit of this PR, it would make sense to rename them as well.
I was trying to get this PR out fast because if we introduce more char-optimized versions, it will mean more and more effort to change it back. Changing existing unmerged PR shouldn't be a huge effort, since it's a simple find-and-replace action.
I still don't understand why that would be the case. Overloads can, technically, be bound just as easily as renames.
I don't understand this point, I think?
In the relevant PR there were several voices in favour of "merging it now but bulk-renaming functions to a non-_char suffix later". I have now created the relevant PR.
The point is that the two function calls will yield equivalent results in all cases: string.find("a")
string.find('a') If the function was named differently, it would imply different behavior. However, the single-char version is merely an optimized case of the full string version. That's the entire reason why i'm against different names.
That's true. I'd be willing to take responsibility and notify authors with affected outstanding PRs in case of a merge. There's ways to search for that (though it's an admittedly manual act). |
Let's not break compatible in classes that don't have support for handling it
They could but we don't have a system for them, so they can't be bound, you can bind a function that has an overload in c++ but the name can't be the same in extensions, which is the entire issue there Essentially we can't have both To explain again, the bound methods can be used in extensions and modules, and it's possible to compile a module either as built into the engine, or as an extension using In those cases only code that's exposed can be used, or it won't compile, so we use I don't see the reason to make these methods different from every other method in this class, they cannot be named the same without forcing us to not exposing them It is far more confusing to have Simply i don't see the logic behind this and to me it goes against established logic and preference for readability By changing them like this we effectively say "we won't ever expose these" which I think is a bad idea To reiterate the issue:
Edit: Realized I had missed that you used |
Alright, to get me to understand, allow me to rephrase your (I think) two overarching points. One is simply that More importantly, you are making the point that the Am I getting your points right? I appreciate your patience in continuing the discussion :) PS. I do think this is a rather awkward limitation of the GDExtension system, but it's obviously out of scope to address that just for this rename. |
You are correct, now this doesn't currently affect us as such, but it would prevent us from binding this very useful method until we support overloads, and that's currently not being heavily worked on and isn't a high priority (it would need GDScript support, the extension side wouldn't be difficult as such, but extension must match scripting) So it's indeed a mix of convention, that we should either change all methods or none, having |
In this specific case, binding against |
We already expose |
Alright then. Thanks again for the explanations. I am closing this PR for the implication that, with the current implementation, this rename would prevent the |
Thank you for resolving this confusing topic! |
Disclaimer: This is a change proposal, so if you have reservations about the rename, please comment them.
In my opinion, there is no real reason for the
_char
suffix. Instead, it reduces findability of these functions.The PR itself is just a find-replace of
find_char(
->find(
andcontains_char(
->contains(
.