smuj wrote:
> Jon Lang wrote:
>> Here's a radical notion: use something other than '#' to initiate an
>> inline comment.
> [snippage]
> Or maybe just don't allow "embedded" comments unless they are actually
> "embedded", i.e. if a line starts with a # (ignoring leading whitespace)
> then it's _always_ a line-end comment, no matter what follows the #, e.g.

That has the advantage of preserving a three-character embedded
comment.  It has the disadvantage that you get differing behavior
depending on where the comment is on the line.  As I see it, the whole
point of this exercise is to get rid of the gotchas, and not just to
shift them around - thus my ':#' proposal.

OTOH, you just (inadvertently?) pointed out that ':#<...>' is very
much like adverbial syntax; this could be quite useful if we ever find
a need for the parser to associate comments directly with code, in
that anything that can take an adverb could theoretically have a
comment associated with it.  But that's a can of worms that doesn't
need to be opened yet, if ever.

> We could always have a Q form in place of #'s to achieve the above effect
> from S02, more like a funny heredoc, e.g.
> Q :#<<<                     # embedded
> sub foo                     # comment
> {                           # extends
>  ...                        # to
> }                           # (wait for it)
>>>>                         # here!
> Maybe call it a "theredoc"! :-)

We can already do this using POD sections:

   =begin comment
   sub foo
   =end comment

I don't see much need for a #-based multi-line comment beyond this.
But it _would_ be nice to be able to indent POD Sections in the same
way that you can indent heredocs.  Especially if the former is
intended to be the standard means of commenting out blocks of lines.

OTOH, let's say for the moment that we choose to extend the analogy
between embedded comments and quotes: one could, in theory, do a
Heredoc-style comment:

   :# <<< END
   line 1
   line 2
   line 3

where ':#' is the comment-equivalent of 'q', whatever that turns out
to be. (I'm not sold on ':#'; but I _would_ like to see a two-symbol
token that begins with a non-'#' and ends with a '#', for conciseness
and clarity.)

Technically, this would also allow for the likes of ':#"comment"'.
But I agree with the gentleman from the original discussion years ago
that we should probably forbid non-bracketing characters when
delimiting embedded comments.

Jonathan "Dataweaver" Lang

Reply via email to