From: Sebastian Gniazdowski <psprint@zdharma.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: Feature request – substitutions similar to +, -, :+, :-
Date: Sat, 25 Nov 2017 12:15:42 +0100 [thread overview]
Message-ID: <etPan.5a1950df.46f9693d.c73c@zdharma.org> (raw)
In-Reply-To: <etPan.5a10805d.57d72d7c.137@AirmailxGenerated.am>
On 18 Nov 2017 at 19:46:18, Bart Schaefer (schaefer@brasslantern.com) wrote:
> If I understand your example correctly, $theme[use-name] is either
> unset/empty, or it contains "1" or "0".
>
> So I think :& is just ${(M)theme[use-name]:#1} and :^ is ${theme[use-name]:#0}.
It looks for me that this would filter value "1" or filter-out value "0". It seems that this doesn't translate to code-shortening one-liner. I was rather wrong in my original post when I wrote about boolean substitutions targetting 0 and 1 values. Direct access to use case is needed to filter useful thing (while I was doing retrospection). However today an IRC user had one use case:
:- does:
if (VAR) { return VAR } else { return "something else"; }
new :- (with proposed :^ form) should:
if (VAR) { return "" } else { return "something else" }
So it's about clearing default output. This would allow somewhat boolean-style code, like:
% DOCS=yes (or DOCS="")
% find ${${DOCS:^Pictures}:-Documents}
This does: If DOCS empty (checked by :^ substitution), then use "Pictures", otherwise, use "Documents" (because :- detects empty default output <-> DOCS is true, not-empty).
For boolean evaluations, clearing actual output is intuitively expected. What's left is just that as long as ^ associates with negation action, a better form would be good, that would associate with empty value, like minus "-", ":-".
--
Sebastian Gniazdowski
psprint /at/ zdharma.org
next prev parent reply other threads:[~2017-11-25 11:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-18 18:05 Sebastian Gniazdowski
2017-11-18 18:22 ` Sebastian Gniazdowski
2017-11-18 18:46 ` Bart Schaefer
[not found] ` <etPan.5a10805d.57d72d7c.137@AirmailxGenerated.am>
2017-11-25 11:15 ` Sebastian Gniazdowski [this message]
2017-12-03 9:11 ` Ternary expression in Zsh (was: Feature request – substitutions similar to +, -, :+, :-) Sebastian Gniazdowski
2017-12-05 6:55 ` Stephane Chazelas
2017-12-05 8:06 ` Tom M.
2017-12-05 9:04 ` Bart Schaefer
2017-12-05 8:24 ` Sebastian Gniazdowski
2017-12-05 9:05 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=etPan.5a1950df.46f9693d.c73c@zdharma.org \
--to=psprint@zdharma.org \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).