Stream: beginners

Topic: Variable name casing for acronyms


view this post on Zulip David Dunn (Feb 01 2023 at 07:36):

The FAQ mentions camelCase as the preferred case for variables. Bit of an edge case, but is there an existing convention for how acronyms should be handled? eg. is it spelt XMLHTTPRequest, XmlHttpRequest or xmlHttpRequest? (or something else?) I'd expect xmlHttpRequest, given how leading caps imply a type and xMLHTTPRequest is likely universally offensive.

What's the analogous convention for types? XMLHTTPRequest or XmlHttpRequest? Looks like XmlHttpRequest, going by Str.Utf8ByteProblem.

Sorry, answered my own question while writing it :sweat_smile:
Should I add this to the FAQ?

view this post on Zulip Richard Feldman (Feb 01 2023 at 11:33):

yeah, should be XmlHttpRequest - but we should write that up somewhere!

view this post on Zulip Richard Feldman (Feb 01 2023 at 11:34):

in fact that's a good example of exactly why this convention exists - the lowercase indicates word boundaries

view this post on Zulip Richard Feldman (Feb 01 2023 at 11:34):

e.g. with XMLHTTPRequest you can't tell where one word ends and the next one begins :sweat_smile:

view this post on Zulip Richard Feldman (Feb 01 2023 at 11:34):

(unless you already know already, of course)

view this post on Zulip Martin Stewart (Feb 01 2023 at 12:27):

I'm guessing it would be paddingXY instead of paddingXy though since X and Y are separate words?

view this post on Zulip David Dunn (Feb 01 2023 at 19:36):

That's a good one too. All caps can be especially confusing when a type is all domain-specific acronyms, like EMVPOS

view this post on Zulip David Dunn (Feb 01 2023 at 19:40):

Richard Feldman said:

yeah, should be XmlHttpRequest - but we should write that up somewhere!

Is the FAQ the right place for this? Thinking of adding it where I found the camelCase recommendation ("No underscores in variable names" in the reasons Roc differs from Elm)

view this post on Zulip Richard Feldman (Feb 01 2023 at 20:13):

both of those sound good to me! as in: both the FAQ and the roc-for-elm-programmers.md document

view this post on Zulip Richard Feldman (Feb 01 2023 at 20:13):

want to make a PR for adding them?

view this post on Zulip David Dunn (Feb 02 2023 at 19:05):

Done!


Last updated: Jul 06 2025 at 12:14 UTC