Re: Syntax of Comments (was: language design tradeoffs)

moss@cs.umass.edu
Wed, 23 Sep 1992 13:10:50 GMT

          From comp.compilers

Related articles
language design tradeoffs kotula@milli.cs.umn.edu (1992-09-07)
Syntax of Comments (was: language design tradeoffs) crowl@jade.cs.orst.edu (1992-09-21)
Re: Syntax of Comments (was: language design tradeoffs) moss@cs.umass.edu (1992-09-23)
Re: Syntax of Comments (was: language design tradeoffs) firth@sei.cmu.edu (1992-09-23)
Re: Syntax of Comments (was: language design tradeoffs) tmb@arolla.idiap.ch (1992-09-23)
Re: Syntax of Comments (was: language design tradeoffs) jlg@cochiti.lanl.gov (1992-09-23)
Re: Syntax of Comments (was: language design tradeoffs) jimc@tau-ceti.isc-br.com (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) crowl@jade.cs.orst.edu (1992-09-24)
Re: Syntax of Comments (was: language design tradeoffs) crowl@jade.cs.orst.edu (1992-09-24)
[12 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers,comp.human-factors
From: moss@cs.umass.edu
Organization: Dept of Comp and Info Sci, Univ of Mass (Amherst)
Date: Wed, 23 Sep 1992 13:10:50 GMT
References: 92-09-048 92-09-134
Keywords: C, parse, syntax, comment

Jim Giles wrote that comment syntax that allows multiple lines to be
commented out tends to lead to inadvertant errors, and suggested ifdef's
as a good approach. Lawrence Crowl responded that line by line commenting
is more clear and is not tedious if you have a decent editor.


I think they're both right, but the problem that Jim Giles points out
comes from treating something like /* .... /* .... */ as a valid comment.
Some languages (notably Modula-3) allow comments to be NESTED, so that one
can comment out a range of code that itself contains comments, without
getting unexpected results. This means that comments can no longer be
described in a regular language (the nesting makes it context free), but
who cares? Any practical lexical analysis technique will support it.


I second the view that ifdef is not a good idea, primarily in that C style
macro processing, at and below the level of tokens, is even more dangerous
and disruptive than a good comment mechanism. One can get by reasonably
well without a C style preprocessor (as is done in Modula-3) or with
macros that have more syntactic robustness (as in Lisp).
--
J. Eliot B. Moss, Associate Professor Visiting Associate Professor
Department of Computer Science School of Computer Science
Lederle Graduate Research Center Carnegie Mellon University
University of Massachusetts 5000 Forbes Avenue
Amherst, MA 01003 Pittsburgh, PA 15213-3891
(413) 545-4206, 545-1249 (fax) (412) 268-6767, 681-5739 (fax)
Moss@cs.umass.edu Moss@cs.cmu.edu
[Many PC C compilers used to accept nested comments, but that practice was
stamped out in later years as annoyingly non-standard. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.