Gale Paeper wrote:
At least according to the documentation, none of the MacPascal dialect compilers allow nested comments in the `{ ... { ... } ... }' form. CodeWarrior Pascal and MPW Pascal compilers support a nest comments Pascal non-standard extension but you must use different comment delimiters for nesting; e.g. '{ ... (* ... *) ... }'.
Are these really nested comments, or are `(*' and `*)' just ignored within a `{ ... }' comment? In the latter case, also `{ (* }' and `{ *) }' would be comments. This (requiring matching delimiters) would be the behaviour of most compilers I've seen (including GPC in non-standard modes).
(As an aside, there is a THINK Pascal add-on tool which provides the sort of capability nested comments are intended to provide. Basicly, it is just a bulk text editor which modifies blocks of program text with specific character formatting markups to indicate the level of commenting out - no non-standard extensions required since it is just a markup convention employed inside "regular" comment delimiters which the add-on tool assists with using the convention.)
That's really something different. As I wrote, the main usefulness of real nested comments to me is to be able to embed formatted text that uses those characters itself, e.g. TeX code (to describe mathematical routines), or the description of regular expressions in the RegEx unit.
CBFalconer wrote:
The other attitude is that the comments are separate beasts, so that (* commment { junk } more *) is a single star comment which happens to include brace characters (and the inverse). Call this nested comments.
I call these non-mixed comments (or more precisely, comments without mixed forms of delimiters). As you wrote, the `{' and `}' in your example are considered ordinary comment characters, not comment delimiters, so it isn't suitable to speak of `{ junk }' as a nested comment; it's just a sequence of ordinary comment characters. (The practical difference is, as above, that non-matching `{'/`}'s are accepted here, unlike with real nested comments.
I don't believe that any system that counts comment opening symbols so as to allow full comment nesting is useful or desireable.
Feel free not to use it. (`--nested-comments' is not the default is GPC, of course.)
If we are agreed on that then the only thing to discuss is whether, having selected the nested/non-nested formats, the appearance of an open-comment marker in a comment should trigger a warning. It is certainly not an error. I consider the warning should always appear, but others may differ. I would call this warn on possible unclosed comments.
I think a warning could be useful, but not always on, i.e. another option. I wouldn't mind if it's on by default. Maybe even in standard modes (though this construct is standard-compliant, we do warn about other standard-compliant constructs, such as unused variables.)
Frank