Hiyas,
Carl Mäsak wrote:
In my post "Three things in Perl 6 that aren't so great" [0], I
outline three things about Perl 6 that bug me at present. Commenter
daxim made what seems to me a sensible proposal [1] for solving the
third problem, "Comments in the beginning of lines":
daxim (]):
] Let single # be used for commenting out, no matter what follows.
] Let ## (perhaps also ### and so on) switch on the special behaviour
] of brackets etc.
I just want to say that this makes sense to me, both from a Huffmanian
standpoint, and from the standpoint of the principle of least
surprise. It doesn't make embedded comments much more convenient,
because C<##(this)> isn't much more cumbersome to write than
C<#(this)>. And it solves the commenting-out-whole-lines problem.
Although I can see some minimal uses for embedded comments, I think in
general the cost/benefit ratio isn't enough to warrant their existence.
I could be wrong of course! :-) I'd like to know if anyone has made much
use of them in their code, and under what circumstances.
If they are to remain, I'd vote for the ## solution (as suggested by
daxim) in order to remove the "gotchas" that are bound to occur
otherwise. Embedded comments should be a "purposeful" thing! I wouldn't
go for "any string of #'s longer than one" as that would require people
to scan every line of #'s just to see if there was something on the
other #############################################################(end)
after an embedded comment.
In the aftermath of YAPC::EU, the question of embedded comments was
also touched upon, and another solution was discussed: leave things as
they are currently specced, but don't consider C<#{> the start of an
embedded comment -- in other words, all other bracketing characters
can still be used to make embedded comments, but the curly braces can
not. This, if I remember the discussions correctly, had two
advantages:
1. It makes it safe(r) for the user to think 'closure' when she sees a
C<{...}> block. Even in interpolated strings, it's a closure.
2. At least parts of the commenting-out-whole-lines problem would go away.
It's not worth the complication IMHO. I would vote, in order of preference:
1) get rid of embedded comments altogether
2) ## followed by _any_ opening bracket character is an embedded comment
It would be nice to hear p6l-ers' reactions on these two proposals. Be
warned, though -- this is a bit of a bikeshedding topic. :) Every one
and his dog is an expert on comment syntax.
I think that's something we can all agree on!! :-)
[0] http://use.perl.org/~masak/journal/39334
[1] http://use.perl.org/comments.pl?sid=43438&cid=69583
Cheers
--
smuj