[Haskell-cafe] Why shouldn't variable names be capitalized?
robdockins at fastmail.fm
Fri Aug 4 14:12:52 EDT 2006
On Aug 4, 2006, at 1:12 PM, Martin Percossi wrote:
> Hi, I'm wondering what the rationale was for not allowing
> capitalized variable names (and uncapitalized type names and
> constructors). I can only think of two arguments, and IMHO both of
> them are bad:
> 1. Enforces a naming convention. Fine - but my view is that this
> doesn't belong in the language definition (it belongs in the user's
> coding standards). I get annoyed, for example, that when I write
> code that manipulates matrices and vectors, I can't refer to the
> matrices with capital letters as is common in the literature.
This is occasionally irritating.
> And to anyone who says that it's good to enforce naming
> consistency, I have this to say: Any language that requires me to
> learn about category theory in order to write imperative code
> should treat me like an adult when it comes to the naming of
> variables as well. ;-)
> 2. It makes it easier to write the compiler. I don't think I need
> to explain why this is bad...
Eh? I'm not convinced this is a bad reason. It obviously needs to
be balanced against other competing factors, but ease of
implementation should always a consideration when designing a language.
3. It removes a whole class of possible ambiguities from the
language. You the programmer (and the compiler, as an added bonus)
can always identify the syntactic class of an identifier from _purely
Suppose I remove the case restriction. Is the following a pattern
match or a function definition? Is M a variable or a data constructor?
let f x M = z M in ....
You can't tell! Worse, it could change depending on what identifiers
are in scope. It could happen that you import a module and it
silently causes your function definition to change to a pattern
match. The situation is similar with type classes and type
variables. You could magically end up with an instance declaration
that is less polymorphic than you expect (if you have extensions
> I imagine that someone is just itching to "sort me out". Do your
> worst! ;-)
Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
More information about the Haskell-Cafe