Comment Syntax
Manuel M T Chakravarty
chak at cse.unsw.edu.au
Thu Feb 2 16:13:59 EST 2006
Josef Svenningsson:
> I'm in favour of changing the comment syntax.
>
> On 2/2/06, Manuel M T Chakravarty <chak at cse.unsw.edu.au> wrote:
> I am against such a change. The change would break existing
> software
> (eg, Yampa) and secondly I don't buy the "main sources of
> confusion for beginners" argument. The confusion arises only
> when a
> single line comment is used to uncomment a set of characters
> that start
> with a special symbol. That's a situation that doesn't arise
> that
> often. (I'd actually be very happy if the main sources of
> confusion fpr
> beginners where of such simple syntactic nature.)
>
> Oh yes, it does happen that a single line comment begins with a
> special symbol. It has happened to me on several occations when using
> haddock annotation to my source code. It is all to easy to forget that
> extra space. With incomprehensible error messages as a result.
I didn't say it doesn't happen. I said, it doesn't happen that often.
Haddock increases the likelihood of it happening, but as Henrik wrote,
well just improve the errors messages a bit. Errors involving operators
starting with -- could specifically suggest that the user might have
wanted a comment, but wrote an operator.
> As for consistency, well if you absolutely want to make it
> consistent,
> impose the same rule on {- as on --.
>
> I still think there is an inconsistency here. And it has to do with
> maximal munch lexing. Maximal munch is what we normally expect from a
> lexer for a programming language. But the way comments work at the
> moment breaks maximal munch. The longest possible read is to read the
> whole line as a comment and not interpret for instance --^ as an
> operator. It breaks any programmers' intuition not only beginners'. I
> still get it wrong from time to time.
That doesn't convince me either. Comment syntax breaks standard lexical
analysis for nested comments anyway (as they are not regular).
And as I wrote before, if we were to design a language from scratch, I
might be persuaded to change my opinion, but if we change the rule for
Haskell now, we break good code. I believe, we should not break good
code without a really good reason. I haven't seen a really good reason
to change the status quo.
Manuel
More information about the Haskell-prime
mailing list