Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Block comments ala Ray
- X-seq: zsh-workers 48013
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Block comments ala Ray
- Date: Fri, 12 Feb 2021 07:41:50 +0100
- Archived-at: <https://zsh.org/workers/48013>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-02/CAN%3D4vMoYj3WbBk3BL98buiYcf7rkLtw%3Db9v_f0p1C4zqYRB7xg%40mail.gmail.com>
- In-reply-to: <CAH+w=7Zd2gY-s5T1dDNEEujAh6197MzrUD-iZrVwZLzD=L7xVQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7YZREq7FbJCCoWoJ-vQ7+P5Z=_mKB-aStoMiBRupqD_wA@mail.gmail.com> <CAN=4vMonpZHPSarsC778_GMbD_h4ioTwT+bTFU=FZ7_zbXaMqQ@mail.gmail.com> <CAH+w=7Zd2gY-s5T1dDNEEujAh6197MzrUD-iZrVwZLzD=L7xVQ@mail.gmail.com>
On Fri, Feb 12, 2021 at 7:17 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> 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.
I understand that Ray wants this but I don't know why.
What are the benefits of this:
!#
Lorem ipsum
dolor sit amet
#!
over this:
# Lorem ipsum
# dolor sit amet
?
Do these benefits justify adding new syntax that's unique to zsh?
> Do you have inline comments in the shell now?
No. I use zsh as my main shell and it doesn't support inline comments.
> Do you only care about
> inline comments that don't contain newlines?
Yes.
I should say that I don't care that much about inline comments. My
point is that I would only ever use block comments as inline comments
with no embedded newlines.
> 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?
If this were valid syntax, I would expect it to work like in C. In
other words, I would expect there to be two commands:
print this
is the rest of the command
> 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.
Ray does many things that I wouldn't recommend ;-)
> Do you not use block comments to delimit expository paragraphs?
No. I mostly write C++ and I use single-line comments for everything
except inline comments (those that don't span until the end of the
line). This is standard practice at Google. I believe this is common
in many other languages that have C-like comments (Java, C#, etc.).
Whenever I worked on a code base that used block comments, they
usually looked like this:
/*
* Lorem ipsum
* dolor sit amet
*/
And almost never like this:
/*
Lorem ipsum
dolor sit amet
*/
So block comments in my experience are most often used as if they were
single-line comments.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author