As an addendum, I think it goes without saying that this is the simplest form of what I proposed:

  # This is a
 comment. #

That denotes a complete comment, which could be broken over lines or not, and the rules for parsing or escaping it would be exactly the same as a character string literal, except for a lack of interpolation abilities, and literal # are escaped.

That is essentially how I do comments in Muldis D, and it works quite well.

-- Darren Duncan

Darren Duncan wrote:
Personally, I think that comments should have trailing # as well as leading ones, so they are more like strings in that the same character is used to mark both ends.

So in combination with bracketing pairs, we could for example have this:

  #{ This is a comment. }#

That also serves to make the comments more whitespace independent, like with strings in general.

I think the trailing # may also resolve some other issues raised in this thread.

Note that my proposal is orthogonal to other issues like double-leading # or whatever bracketing chars are used.

Also note that if the # are treated more like delimiters, then potentially we could also have \# to escape literal #, same as we have \' or \" etc.

Having # at both ends makes it easier to see at a glance where comments begin and end, and potentially it makes it easier to make a parser or syntax colorer.

Reply via email to