Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Block comments ala Ray
- X-seq: zsh-workers 48046
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Block comments ala Ray
- Date: Sun, 14 Feb 2021 12:15:31 -0800
- Archived-at: <https://zsh.org/workers/48046>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-02/CAH%2Bw%3D7Yydsx6QMhmKj5V_TX6-0sLKo9nNm3t07fsnhd5SKGj8Q%40mail.gmail.com>
- In-reply-to: <20210213083521.kv3y3qzfnaffflfh@chazelas.org>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7YZREq7FbJCCoWoJ-vQ7+P5Z=_mKB-aStoMiBRupqD_wA@mail.gmail.com> <20210213083521.kv3y3qzfnaffflfh@chazelas.org>
On Sat, Feb 13, 2021 at 12:35 AM Stephane Chazelas
<stephane@xxxxxxxxxxxx> wrote:
>
> 2021-02-09 22:05:13 -0800, Bart Schaefer:
> [...]
> > !# This begins a block comment.
> > This is merely rambling.
> > This #! is the last line of the block
> [...]
>
> - those !#, #! look too much like a shebang.
Which actually doesn't matter, because #! isn't special anywhere but
the first line.
> - !# is already histsubst syntax.
Also doesn't matter, this was intended only to operate where history
is disabled anyway.
> - It's also the !# extendedglob
You mean "zero or more occurrences of '!' "? This is another reason I
was only allowing "!#" at the start of a line. Under what
circumstances would you begin a new line with that glob?
> - It's also (POSIXly) invoking the !# command.
Yes, I mentioned that. It seems pretty damn unlikely to use that, as
it has no effect other than to set $? to 1.
> Also consider
> scripts that do:
>
> cat > script <<EOF
> #! /bin/sh -
> ...
> EOF
>
> making it difficult to comment out those codes
That one has some relevance, and argues for requiring #! to be
followed immediately by a newline, if not also preceded by one.
> - syntax is a bit obscure and uncommon.
Intentionally so, yes. It has to be something that would essentially
never appear in an existing script.
> Would we allow blanks
> before the !# for indentation purposes.
No.
> Would those !# be
> recognised if the previous line ends in a \ or inside
> heredocs?
No, because it's handled by the lexer. It's not recognized anywhere
any other comment isn't.
> Does it have to be delimited with whitespace? Can we
> use !########### .. ##############!? That ! is easy to miss.
Those are among the reasons I didn't think forming "inline comments"
was a good idea.
> Would we allow escaping the closing #!? How?
No, because you can't escape anything inside a comment.
> - assuming we allow nesting (which would be useful to comment
> out sections of code that contain block comments),
I hadn't considered nesting. You can't nest C /* ... */ comments, and
this was not intended to work any differently.
> - <<# .. #>> allows inline comments, but looks more like a
> redirection operator than a comment.
That's why I rejected <# ... #>.
> To me, there are more useful features that could be added to zsh
> before that one.
This is like saying we should solve problems on earth before we spend
money on space exploration. It's a false dichotomy.
> Or ksh's <#((...)), <#.. <>; redirection operators.
The possibility of wanting to add those would also argue against using
"<#" or "<<#" as a comment introducer.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author