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

Make ucfirst a method of uppercase #21910

Open
dpsanders opened this issue May 16, 2017 · 9 comments
Open

Make ucfirst a method of uppercase #21910

dpsanders opened this issue May 16, 2017 · 9 comments
Labels
speculative Whether the change will be implemented is speculative strings "Strings!"

Comments

@dpsanders
Copy link
Contributor

E.g. with a keyword argument.

@ararslan ararslan added speculative Whether the change will be implemented is speculative strings "Strings!" labels May 16, 2017
@stevengj
Copy link
Member

stevengj commented May 18, 2017

Why? In most languages this (or its analogue) is a distinct function (e.g. ucfirst in Perl, capitalize in Python or Ruby, titleize in Rails, Title in Go)....

We also have the titlecase function to capitalize each word in a string (#19469).

@stevengj
Copy link
Member

stevengj commented May 18, 2017

Arguably, ucfirst should convert the first character to titlecase, not to uppercase, however (mentioned in #11471). This is the same for ASCII, but e.g. dž (U+01c6) would be converted to titlecase Dž (U+01c5) rather than to uppercase DŽ (U+01c4).

The Perl ucfirst function uses titlecase.

@dpsanders
Copy link
Contributor Author

The reasoning is to reduce API bloat, and because the name ucfirst does not tell me what the function does, since it uses an incomprehensible and non-standard abbreviation.

@dpsanders
Copy link
Contributor Author

Actually, capitalize is not bad.

@stevengj
Copy link
Member

Honestly, I don't see why we need ucfirst given titlecase. I would think that in most circumstances where you'd use ucfirst, it would be for strings consisting of a single word, in which case titlecase(s) would be equivalent.

@stevengj
Copy link
Member

I found 17 packages using ucfirst, and in all of them, as far as I can tell, they are applying it to single words where titlecase would work as well.

@dpsanders
Copy link
Contributor Author

Closing, since ucfirst has now been moved to the Unicode stdlib package.

@rfourquet
Copy link
Member

Closing, since ucfirst has now been moved to the Unicode stdlib package.

But there is no separate issue tracker for stdlib packages, so couldn't this be left open?

@StefanKarpinski
Copy link
Member

Yes, this is a good reason to move stdlib packages into their own repos at some point, but we're not there yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
speculative Whether the change will be implemented is speculative strings "Strings!"
Projects
None yet
Development

No branches or pull requests

5 participants