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

Re: Feature request: a new warning option



Roman Perepelitsa wrote on Wed, Oct 09, 2019 at 15:40:48 +0200:
> Supposing that "if-then-else is too verbose" is a problem that
> warrants extending zsh, a natural solution would be to provide an
> alternative syntax for the same construct. Something analogous to
> `x ? y : z` from C and other languages derived from it.

Extending the SHORT_LOOPS form of «if» to allow an «else» comes to mind, but
I'm honestly not sure if it'd be a good change to make.

> Note that C had an extra reason besides terseness to introduce this
> syntax: if-then-else is a statement while the ternary is an
> expression. This reason doesn't apply to zsh, which leaves saving
> on typing as the only benefit of the contemplated innovation.
> Since `x ? y : z` already has a meaning in zsh, the new syntax would
> have to be different and likely unfamiliar to users.
> 
> All-in-all, doesn't seem worth the trouble. if-then-else has the
> desired semantics, isn't more verbose than in other languages,
> and is easy to read even for people unfamiliar with zsh.

Cheers,

Daniel



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