Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Block comments ala Ray



On Tue, Feb 9, 2021 at 10:16 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> On Wed, Feb 10, 2021 at 7:05 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > !# This begins a block comment.
> > This is merely rambling.
> > This #! is the last line of the block
>
> This can be very surprising because it's not how block comments work
> in other popular languages.

I don't find that very compelling, because in shell the alternative is
to prefix every line with "#", which is exactly what Ray wants to
avoid.

It might be possible to force it to look

!#
like this
#!

(that is, require newlines both before and after the delimiters), if
that seems more friendly, but then the question is what

!#
this
#! means

(did the block end, and if it did not then ...)?

> It also disallows inline comments --
> something I personally use in other languages.

Do you have inline comments in the shell now?  Do you only care about
inline comments that don't contain newlines?  As I mentioned, I
experimented with

print this <# is an inline #> comment

because "<#" in any existing script would be a syntax error; but as
soon as you allow newlines within the comment it becomes a verbose
form of backslash-newline continuation, which felt wrong.

Do you disagree with me about how strangely this --

print this <# part is a comment
(lah-di-dah for perhaps hundreds of lines)
but this part #> is the rest of the command

-- implicitly behaves if the embedded newlines can be inlined?

> I would go even further and say that the value provided by block
> comments resides almost exclusively in enabling inline comments.

I think Ray at least disagrees with you, since he's willing to abuse
here-documents for the purpose, which also can't be inlined.

Do you not use block comments to delimit expository paragraphs?




Messages sorted by: Reverse Date, Date, Thread, Author