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

Re: Block comments ala Ray



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
[...]

I can't say I like it much either.

- those !#, #! look too much like a shebang. Also consider
  scripts that do:

  cat > script <<EOF
  #! /bin/sh -
  ...
  EOF

  making it difficult to comment out those codes

- !# is already histsubst syntax.

- It's also the !# extendedglob

- It's also (POSIXly) invoking the !# command.

- syntax is a bit obscure and uncommon. Would we allow blanks
  before the !# for indentation purposes. Would those !# be
  recognised if the previous line ends in a \ or inside
  heredocs? Does it have to be delimited with whitespace? Can we
  use !########### .. ##############!? That ! is easy to miss.
  Would we allow escaping the closing #!? How?

- assuming we allow nesting (which would be useful to comment
  out sections of code that contain block comments), it will be
  harder to follow than with C's #if...#endif or
  :||:<<'EOC'...EOC

Other possible avenues:

- <<# .. #>> allows inline comments, but looks more like a
  redirection operator than a comment.
- alternatively: <<#EOC .. EOC (or <<#{...} <<#[...] and the
  usual pairs) to make nesting easier.
- The =word .. =cut of perl: conflicts with zsh's =cmd operator,
  not nestable put would allow pod inline documentation.

To me, there are more useful features that could be added to zsh
before that one. In that vein, I'm thinking of quotes like
python's '''...''' or perl's q(...)/qq(...) or ruby's %q{...}
operator for things like

ssh host %{
  blah | sed 's/\./.../'
}

Or ksh's <#((...)), <#.. <>;  redirection operators.

-- 
Stephane




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