[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nested comments, 4
From: Kevin Hammond <kh@cs.glasgow.ac.uk>
Date: Thu, 20 Sep 90 20:29:58 BST
To: haskell@cs.glasgow.ac.uk
Subject: Re: nested comments, 4
Sender: haskell-request@cs.glasgow.ac.uk
> More on comments (and strings):
> -------------------------------
>
> By the way, why may I not have a comment at the end of ANY line in a
> Haskell program? E.g.:
>
> "This is a \ -- This is a *currently illegal* comment!
> \string which was written \
> \with \"gaps\" in the program."
Earlier versions of Haskell had exactly this feature. This added
complexity to the lexical analysis which was felt to be unjustified for
such an infrequently used feature (the string analysis would also need
to cope with NESTED comments, not just EOL comments, this can be
ANNOYING for automatically generated lexers). There are several obvious
advantages to reducing language complexity.
You can have exactly what you want with:
"This is a " ++ -- This is a legal comment!
"string which was written " ++
"without \"gaps\" in the program."
(in odd contexts you might need to parameterise the string). Since
most compilers will fold constants, you should lose no performance
by using this string.
It is moot whether gaps themselves are needed (given the orthogonality
of the Haskell design, it isn't obvious that a gap can ever be used
where ++ cannot). Eliminating gaps would restore the property that
"--" comments could appear at the end of any line. The current design
is however consistent with ANSI C.
Kevin