rust-rgb icon indicating copy to clipboard operation
rust-rgb copied to clipboard

CamelCase for acronym typenames?

Open lo48576 opened this issue 5 years ago • 1 comments

Rust's RFC 0430 about naming conventions says:

In CamelCase, acronyms count as one word: use Uuid rather than UUID.

For consistency among other codes, I think RGB and RGBA should be Rgb and Rgba. (RGBA looks like a constant rather than a type.)

What do you think?

lo48576 avatar Jul 28 '19 05:07 lo48576

I have conflicted feelings about this.

On one hand, it'd be nice to follow an official recommendation. OTOH that looks weird to me. In non-Rust languages it's RGB or rgb, but I don't remember ever seeing Rgb.

kornelski avatar Jul 28 '19 10:07 kornelski

I think same-language conventions have greater value for code readability than across-language conventions. As such I am in favor of this change.

ripytide avatar May 23 '24 13:05 ripytide

Also worth adding the RGB8 -> RgbU8 suggestion from #62 here for visibility.

ripytide avatar May 23 '24 15:05 ripytide

Yeah, I'm not sure about this. RGB is a super-common acronym, and the Rgb spelling is mostly a Rust convention, and it looks odd to me especially when not part of a CamelCase name. RGB8 is widely recognized in the industry, and RgbU8 is a Rusty neologism. So I'm torn between being consistent with Rust vs consistent with pretty much everything except Rust.

It is possible to support both, by re-exporting the other with #[doc(hidden)], but one of them needs to be chosen as the canonical. I'm still leaning towards RGB and RGB8.

kornelski avatar May 23 '24 16:05 kornelski

RGB is a super-common acronym

HTML, CSS, HTTP are all commonly-known acronyms, but crates that implement their types all use the rust naming conventions for types using them such as Http in hyper, Css in cssparser, and Html in html. To break this language convention is the greater surprise in my opinion.

The principle of least surprise.

Since you are split fairly evenly between the two options can I suggest we default to Rgb since that is likely to be more familiar to the target-audience of this library (rust-developers) as opposed to the greater industry?

ripytide avatar May 23 '24 17:05 ripytide

OK, that makes sense

kornelski avatar May 23 '24 18:05 kornelski