-
-
Notifications
You must be signed in to change notification settings - Fork 741
Make std.utf module CTFEable #1443
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
Conversation
if (is(S : const char[]) || | ||
(isRandomAccessRange!S && is(Unqual!(ElementType!S) == char))) | ||
if (is(S : const char[]) || | ||
(isRandomAccessRange!S && is(Unqual!(ElementType!S) == char))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you changing all of this formatting? It has nothing to do with the bugs that you're trying to fix, and the module is fairly consistent the way that it is. All of these format changes are clogging the diff without adding any value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we should improve code format style.
I know there are some opposite opinions about template constraint indentation style.
But from my experience, I think this is practically better.
If template constraint is very long, one level indentation will decrease column count that would be able to use for actual code formatting.
For example, let's see std.algorithm.sort
:
SortedRange!(Range, less)
sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
Range)(Range r)
if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range ||
hasAssignableElements!Range)) ||
(ss != SwapStrategy.unstable && hasAssignableElements!Range)) &&
isRandomAccessRange!Range &&
hasSlicing!Range &&
hasLength!Range)
VS:
SortedRange!(Range, less)
sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
Range)(Range r)
if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range ||
hasAssignableElements!Range)) ||
(ss != SwapStrategy.unstable && hasAssignableElements!Range)) &&
isRandomAccessRange!Range &&
hasSlicing!Range &&
hasLength!Range)
If the column limit is 80:
- With first style, you can use 80-8 columns for the constraint expression formatting.
- With second style, you can use 80-4 columns for the constraint expression formatting.
This 4-column difference is not small, when considering word wrapping.
Btw, I'm separating commits based on the changing purpose.
You can see diffs on each commits. There's no clogging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The limit isn't 80. The limit is 120. We have a soft limit of 80 and a hard limit of 120. That seriously mitigates the wrapping problem. It should be relatively rare that function parameters have to go on a second line.
In general, I oppose commits that simply reformat code, especially when it's altering the existing formatting style of the module. Your changes are changing the style of the module, which I object to. We have not agreed on a general style for modules but rather that each module should be internally consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I reverted template constraint indent change. But other style changes (detab and inserting one space after if
etc) are kept because they would increase style consistency in std.utf
module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Thanks.
The diffs that actually do something (1 & 5) look good to me. So lots of noise, but looks good to me. |
Changes
toUTFz
CTFEable.Additionally fixes a found bug:
Issue 10732 - Example code for std.utf.toUTFindex does not work