From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29002 invoked by alias); 25 Nov 2017 11:24:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42050 Received: (qmail 3219 invoked by uid 1010); 25 Nov 2017 11:24:23 -0000 X-Qmail-Scanner-Diagnostics: from aok120.rev.netart.pl by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(85.128.245.120):SA:0(-1.9/5.0):. Processed in 1.881825 secs); 25 Nov 2017 11:24:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: psprint@zdharma.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new using ClamAV (18) Date: Sat, 25 Nov 2017 12:15:42 +0100 From: Sebastian Gniazdowski To: Bart Schaefer Cc: "=?utf-8?Q?zsh-workers=40zsh.org?=" Message-ID: In-Reply-To: References: Subject: Re: Feature request =?utf-8?Q?=E2=80=93_?=substitutions similar to +, -, :+, :- X-Mailer: Airmail (442) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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