Re:Why Pascal Is Not My Favorite Programming Language (1981)
by jstimpfle on Monday February 25, 2019 @07:35AM
(#19245145)
Yes, C has that too. It has different namespaces for struct, union, and enum. And I like the clarity of the explicit namespace prefixes at each place of reference. But I tend to not rely on that distinction, since C++ has only a single namespace.
And as soon as we go to more dynamic languages, where types can also be variables, it all breaks down.
Re:Why Pascal Is Not My Favorite Programming Language (1981)
by kbp on Monday February 25, 2019 @08:22AM
(#19245401)
I was just saying that there's no good reason to have different variables with names that only differ by case; the example you gave where you do like that has a better solution in multiple namespaces.
There's no reason that types and variables need to live in the same namespace. The language can know what it's expecting at a certain point. Putting them in different namespaces, like Lisp does, lets you re-use the same name for types and variables even with matching case, and is more waterproof with regards to clashes than a case convention.
> There simply isn't any good reason not to always use the same case for any variable throughout a project.
I agree, but I also feel that there isn't any good reason to have multiple distinct objects in the same namespace whose names differ only by case. It just seems like a recipe for confusion.
When I'm quickly iterating on something, it's nice being able to be lazy and inconsistent with capitalisation. Standardising that in a codebase is important, but it's more of a job for a linter, I think.