[sc34wg3] Multi-line comments in CTM

Xuân Baldauf xuan--sc34wg3--isotopicmaps.org at baldauf.org
Mon Jan 21 12:39:48 EST 2008


Steve Pepper wrote:
> Multi-line comments are therefore an absolute must for me.
>   
The same for me.

(The little experience I got when writing documents in CTM as of
http://www.itscj.ipsj.or.jp/sc34/open/0935.htm provided that insight.)

As I can see, there are these variants being discussed:

   1. single-line-comments
   2. multi-line-comments
         1. non-nestable
         2. nestable

Nestable comments have the technical disadvantage of making a language
non-regular. However, for practical matters, this is not really an
issue, there are techniques known for nearly all parser generators to
handle nesting comments. As I plan to write a CTM parser as well (and
gained some experience when trying write a usable grammar for CTM as of
0935.htm), I think the advantages of nestable comments outweigh the
additional effort needed, namely allowing to simply place a
comment-start-sequence somewhere and a comment-end-sequence somewhere
else and it "just works". I consider the example

    Robert Barta wrote:
>     -----------------------------------
>
>     /* this is /* also a comment */ 
>     but is this still comment ? */
>
>     ------------------------------------
>         

to be a very practical one.

So, if nestable multi-line-comments have less problems than non-nestable
multi-line-comments from a usability POV (which I think is the case),
then I'd opt for nestable multi-line-comments.


Regarding single-line-comments:

   1. Each single-line-comment can be emulated by exactly one multi-line
      comments, but you cannot emulate each multi-line-comments by
      exactly one single-line-comment. Thus, multi-line-comments are
      more generic. Thus, having multi-line-comments actually satisfies
      people who want to comment only one line, and thus provides
      "comparably more satisfaction" than single-line-comments.
   2. Furthermore, if you view a CTM document as a stream of characters,
      the questions are just about which "comment-start-sequence", which
      "comment-end-sequence". For single-line-comments, the
      "comment-end-sequence" is, by definition, also a
      "line-end-sequence". However, the "line-end-sequence" has a
      meaning for the user which is entirely orthogonal to the meaning
      of being a "comment-end-sequence" (namely, the meaning is
      representing an end of a line). The good principle of Separation
      of Concerns (known already by Dijkstra) gives us a "strong hint"
      to not have one sequence with two separate meanings. (Actually,
      not having one string of bytes with two separate meanings is quite
      important principle in Topic Maps, isn't it?) It is just unclear
      for me why to not allow line-end-sequences within comments.


ciao,
Xuân.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.isotopicmaps.org/pipermail/sc34wg3/attachments/20080122/b9c39000/attachment.html 


More information about the sc34wg3 mailing list