[Haskell-cafe] Comment Syntax

Daniel Fischer daniel.is.fischer at googlemail.com
Mon Jun 6 19:34:57 CEST 2011


On Montag, 6. Juni 2011, 19:08, Albert Y. C. Lai wrote:
> > Bearing in mind that the characters that have been used to begin
> > end of line comments include *, /, ;, !, #, %, and $, it's not
> > clear that there's anything _that_ regrettable about "-- ".
> 
> Recall that the problem is not with isolated characters, but whole
> strings.
> 
> "-- a" is a comment, "--a" is a comment, but "---a" is not.

It is. Report, section 2.3:

'An ordinary comment begins with a sequence of two or more consecutive 
dashes (e.g. --) and extends to the following newline. The sequence of 
dashes must not form part of a legal lexeme. For example, “-->” or “|--” do 
not begin a comment, because both of these are legal lexemes; however “--
foo” does start a comment.'

A sequence of two or more dashes does not begin an end-of-line-comment if 
and only if it is part of a lexeme containing only symbols and at least one 
non-dash symbol.

It might be a good idea to include whitespace in the comment delimiter: 
end-of-line-comment is begun by whitespace--{-}whitespace.




More information about the Haskell-Cafe mailing list