Newsgroups: comp.lang.misc Path: utzoo!utgpu!jarvis.csri.toronto.edu!turing.toronto.edu!holt From: holt@turing.toronto.edu (Ric Holt) Subject: Re: language commenting constructs Message-ID: <89Mar15.085523est.4328@turing.toronto.edu> Organization: /usr/local/lib/organization References: <1543@zen.UUCP> <10460@lanl.gov> Date: Wed, 15 Mar 89 08:55:09 EST > >I do these things because I have learned that it is not safe to >do otherwise. The comment syntax which requires explicit termination >of comments _IS_ more difficult to learn to use safely. The safe >use of the construct is also (marginally) more difficult in actual >use. It is doubtful that anyone designing a new language would >consider the old-fashioned C-like syntax to be desireable. There is no doubt that errors from unclosed comments are difficult to spot and that they occur often enough in practice. The design of the commenting convention in Turing had as a goal to avoid this problem and to minimize the lexical space/confusion of a commenting convention. Hence, comments begin with % and run to the end of the line, as in: % Here is a comment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % Block comment % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% var x : real % Comment at end of a line x := 9.7 % loop % % A nested comment % x += .03 % exit when sqrt(x) > 503 % end loop The last five lines illustrate how you get "nested comments" using %. This is done by having the editor put a % at the beginning of the lines you want commented out. You can, of course, do this repeatedly. And there is no possibility of unclosed comments. Although this is a "complete" convention for commenting, Turing goes ahead and supports, as well, comments of the form /* ... */, but these cannot be nested, to avoid the well known problems with failure to close these.