On Wednesday, 9 May 2018 at 09:38:14 UTC, BoQsc wrote:
The D Style suggest to camelCase constants, while Java naming
conventions always promoted uppercase letter.
Is there an explanation why D Style chose to use camelCase
instead of all UPPERCASE for constants, was there any technical
problem that would appear while writing in all UPPERCASE?
Java language references:
https://en.wikipedia.org/wiki/Naming_convention_(programming)#Java
https://www.javatpoint.com/java-naming-conventions
http://www.oracle.com/technetwork/java/codeconventions-135099.html
https://medium.com/modernnerd-code/java-for-humans-naming-conventions-6353a1cd21a1
D lang reference:
https://dlang.org/dstyle.html#naming_constants
It is really helpful to write generic code. E.g. you use
`myRange.empty` and you do not care what `empty` actually is. The
range could be infinite and define `enum empty = false;` If you
use an uppercase identifier like `EMPTY`, generic code breaks; if
you don't but do otherwise, where is the boundary? The only
solution is, you don't spell it different if something is a
compile-time constant or not.
It is even possible that some name can refer to a type, which is
usually spelled with the first letter uppercase, or a value.
On [1] it reads: `hook` is a member variable [of type `Hook`] if
it has state, or an alias for `Hook` [the type itself] otherwise.
So, generally, anything is spelled camelCase except declared
types as classes, interfaces, structs, unions, and aliases for
things definitely known to be types.
[1]
https://dlang.org/phobos/std_experimental_checkedint.html#.Checked.hook