Article View: comp.lang.misc
Article #6319Re: language commenting constructs
From: Jim Giles
Date: Fri, 17 Mar 1989 01:40
Date: Fri, 17 Mar 1989 01:40
47 lines
2369 bytes
2369 bytes
From article <7555@killer.Dallas.TX.US>, by elg@killer.Dallas.TX.US (Eric Green):
> in article <10460@lanl.gov>, jlg@lanl.gov (Jim Giles) says:
>> do otherwise. The comment syntax which requires explicit termination
>> of comments _IS_ more difficult to learn to use safely. The safe
>> [...]
> In a recent program, I have code similiar to the following: */
>
> /* table */
> int Transitions[NUMSTATE][NUMCLASS] = {
> /* statenum digit number delimiter quote EOF EOL ... */
> /* 0 */ 2, 5, 8, 15, 10, 19,
> /* 2 */ 4, 19, ....
>
> [...] When I do assembler or Lisp I regularly run into
> situations where I want to imbed a comment into a statement for
> clarity's sake, and can't do it.
Please read my original comment again. I only oppose a comment syntax
which _requires_ explicit termination. I don't oppose a comment syntax
which _allows_ explicit termination so long as the end of record also
terminates the comment. My favorite syntax for what you have above
would go something like this:
! table
int Transitions[NUMSTATE][NUMCLASS] = {
! statenum digit number delimiter quote EOF EOL ...
! 0 !! 2, 5, 8, 15, 10, 19,
! 2 !! 4, 19, ....
! 5 !! ....
! ....
Here the comments begin with ! and end with !! or the end of line. This
syntax even allows code (that doesn't include !!) to be 'commented out':
a = b+c
! x = a*(z+y) ! trailing comment
for ( ...) ...
Here the second statement was commented out. The extra exclamation point
doesn't effect the fact that the comment ends at the end of line. As I
say, this only works on lines that don't contain an explicitly termionated
comment. But, since I prefer ifdef for removing code, this doesn't
matter much. This can't be done with C, of course, since ! is an operator
in C. But the C++ syntax ('//') might be extended (terminate comments
with '\\' maybe).
J. Giles
Technical Details
Message-ID:
<10581@lanl.gov>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!cmcl2!lanl!jlgReferences:
<7555@killer.Dallas.TX.US>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.misc Subject: Re: language commenting constructs Message-ID: <10581@lanl.gov> Date: 17 Mar 89 01:40:13 GMT References: <7555@killer.Dallas.TX.US> Organization: Los Alamos National Laboratory Lines: 47