If I wasn’t meant to use variables and types whose name differs only by a single capitalization, the language wouldn’t be case-sensitive.
As someone who is only a beginning programmer – this makes me sick. LinkedList and linkedlist and Linkedlist and linkedList all doing completely different things? (Not even mentioning abominations like LiNkEdLiSt) Is this hell? Are you the devil @nuclearspaceheater?
programming, much like any other form of magic, demands great attention to the fine detail of how things are phrased.
One time I spent like an hour trying to debug a thing because I typed organizationID instead of organizationId. Frankly, it sucked.
in Java, you want to write
LinkedList linkedList=new LinkedList();
or something similar. There is a language, the name of which eludes me at the moment, that is really of the devil: You can use the same identifier to mean different things based on syntactic position.
so
List List = new List();
is a valid line.
C# maybe? The language where
async async async(async async)
is a valid function signature.
(Not that C# is ultimately all that unreasonable! The issue being that any keyword you didn’t reserve in advance is a almost certainly a valid identifier, so you either add keywords that can be used as identifiers (C#) or reuse existing ones with new meanings in new contexts (Java)).
On the other hand, in C++
std::unique_lock(mutex);
is a declaration of a variable named “mutex” and not a call to a std::unique_lock constructor. But if unique_lock didn’t have a parameterless constructor, then it would have been a constructor call using the mutex as a parameter, which is what you were trying to do in the first place. It is really of the devil.
Hold on, what?
Does that work for every class that has a parameterless constructor?
Can I do std::string(foo); and get an empty string object with the name “foo” ?
Is there any way this is different from std::string foo;?