[Haskell-cafe] Comment Syntax

Daniel Fischer daniel.is.fischer at googlemail.com
Mon Jun 6 20:51:16 CEST 2011

On Monday 06 June 2011, 19:51:44, Albert Y. C. Lai wrote:
> On 11-06-06 01:34 PM, Daniel Fischer wrote:
> > On Montag, 6. Juni 2011, 19:08, Albert Y. C. Lai wrote:
> >> 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:
> Sorry. Then "--|" is not a comment. In C++, "//|" is a comment (compare
> with Haskell's "--|"!).

True. But then, to my knowledge, C++ has a fixed small set of operators, so 
the problem of a comment delimiter possibly being part of a different 
lexeme doesn't arise there.
There is, however, a somewhat similar problem in C and C++:

z = *x/*y; // oops */

Back to Haskell: I agree, the choice of the comment delimiter was not the 
best in light of the possibility to define operators containing it as a 
substring. But changing it to have "--|" start a comment too might break 
too much code (and eliminating "--" as a comment starter would certainly 
break far too much code).

More information about the Haskell-Cafe mailing list