Add strfmt macro function instead of changing strformat#5349
Merged
kwvanderlinde merged 1 commit intoRPTools:developfrom Apr 4, 2025
Merged
Add strfmt macro function instead of changing strformat#5349kwvanderlinde merged 1 commit intoRPTools:developfrom
kwvanderlinde merged 1 commit intoRPTools:developfrom
Conversation
Contributor
Author
|
This will conflict with #5343 when release-1.17 is merged back into develop. If you would like to do that first I can rebase this change on top. |
Collaborator
|
Created #5351 to merge release-1.17 first. |
Member
And it has now been merged |
Macros depend on the behaviour of strformat bypassing interpolations if there are no passed parameters, contrary to documentation, so strformat's behaviour can't be changed. Instead we can introduce a new strfmt macro function with more well-defined behaviour of always handling String.format escapes and also not processing the interpolations if you use both interpolations and positional formatting.
Contributor
Author
|
Thanks, rebased. |
kwvanderlinde
approved these changes
Apr 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
fixes #5226
Description of the Change
Macros depend on the behaviour of strformat bypassing interpolations if there are no passed parameters, contrary to documentation, so strformat's behaviour can't be changed.
Instead we can introduce a new strfmt macro function with more well-defined behaviour of always handling String.format escapes and also not processing the interpolations if you use both interpolations and positional formatting.
Possible Drawbacks
Having both strformat and strfmt is confusing. strformat should be deprecated but it is slightly faster if you are only interpolating strings.
Documentation Notes
strfmt behaves like strformat is documented to.
strfmt and strformat should share a wiki page and behaviours where strformat diverges should be documented, i.e.
Formatting Data Type
NOTE: These format specifiers are ignored if
strformatis used and no positional arguments are provided, so %% and %n format specifiers are ignored. Usestrfmtif format specifiers are required without positional arguments.Formatting by Embedding Variables
NOTE: The contents of the variables are interpreted as format specifiers if
strformatis used and positional arguments are provided, so a string containing the value "100%" may be interpreted as a format string and cause errors. Usestrfmtif embedded variables and positional arguments are both used and the variables may contain % characters.Release Notes
strfmtmacro function to replacestrformatso %% and %n format specifiers may be used without positional parameters and allow mixing Variable Embedding with positional formatting.strformatis retained with the previous behaviour for compatibility with existing macros.This change is