3 ms·
I like the notion of discriminating the general kind that names refer to with different separation styles. I think the most common are: - camelCase - PascalCa
by dgb23 4y ago
I like the notion of discriminating the general kind that names refer to with different separation styles. I think the most common are:
- camelCase
- PascalCase
- snake_case
- kebab-case
- |sentence case|
I think the last one can be used in CL, but not 100% sure.
Some examples:
- Clojure prefers kebab-case mostly, but some types and definitions use PascalCase to imply that there is a more direct mapping to a Java class. Clojure prefers to use namespaces to name things that belong together over long, prefixed names. Single letter names are common for function parameters such as 'm' for maps, 's' for strings and so on.
- Go prefers camelCase for private/local types fields and functions. When PascalCase is used, then the name is exported. Go generally prefers short, often abbreviated names (Unix/C heritage).
- Rust prefers PascalCase for type definitions, snake_case for function names, locals and parameter names.
- Both in Go and Rust, packagas/modules/crates give additional naming structure but also control visibility. So those things have multiple jobs.
So generally the-wayWe_Type/And-NameThings in different languages can give us a bit more structure and meaning without cluttering the syntax with additional keywords. A big side-benefit is that we then don't need to decide which style to use! It's better to have a uniform style than your personally preferred one IMO.
- kagevf 4y ago> I think the last one can be used in CL, but not 100% sure. You can create a symbol that way: (let ((|my symbol| 123)) |my symbol|) => 123
- toastal 4y agoIf you think that last bit of wacky casing combinations is offensive, wait BEM-style CSS selectors—not the philosophy or separation of components, just the selectors themselves. Basically any other naming or separator selection would have been better.
- atombender 4y agoI never understood why some languages like Rust are so inconsistent here: snake_case for non-type identifiers, but PascalCase rather than Snake_Pascal_Case for types. Maybe OP's study is real, but the underscore has always bothered me. I'm fine with it in principle, but it creates visual noise, since pretty much all fonts put the underscore below the baseline. Here's a mockup that fixes the vertical placement of the underscore (right hand side): https://i.imgur.com/5sF3QMH.png https://i.imgur.com/5sF3QMH.png Much better!