Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Support the mksh's ${|func;} substitution
- X-seq: zsh-workers 44748
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: [PATCH] Support the mksh's ${|func;} substitution
- Date: Tue, 10 Sep 2019 20:21:01 +0200
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vw7AwzazZlcGRtGvDqu+Sq0TX9sk6iYG3UNthPiTl2U=; b=Ox0MSrek1jXP/2+8Ws5MugzigUnwu2lGJpDqy7OuJr9OzTYKB/MrJGDkZpq3m+oZiZ sqsCtS1/QEBM6ZvHvvo4wO5VvYRud1zzEgyyFN4eFIl1PojavC0gVruvr67WXRxeyl4l obeMFRY114bJ8A9aj2+SwJp6TqGxmkBWmXN6cccS/VNbGQNHdxDWMMguSmf9hANWr6/L Uq1HvVK+LbWB+vijihwz8Ke8W1FNPWaBoLBoGo148nzulBzcMvG4ExUoXWgh5OHt2PEk Q5xrKFX69O++0PSbeMYNYc7xD+KmsDDUCX3/AjkIMTPkPhSKoUBKGTq3l8WX4TCKxPLf 402w==
- In-reply-to: <CAH+w=7YL25JXUs5aHFtfNvs0WddC-JoDZtv-0+7O1sxkeEaOAg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBTw2j=awaf0wAkyyO08k=vossU28fvZ=s+fhqMkcKuJQ@mail.gmail.com> <20190907150741.jwztdoslrvk5j7nk@chaz.gmail.com> <CAKc7PVDC6NULei7FCKXvHu1YRzhmk9ZJK4BECRRxpWNQpHCw9w@mail.gmail.com> <20190907201954.dn2nve65wqk4muvc@chaz.gmail.com> <CAKc7PVB-V8Gqd2Pg8X=YjQDyPC=zG3keaKtdiS8cFCgfUOT_EA@mail.gmail.com> <CAKc7PVCLpZ6_+bK8iQW0qPLB0t-iNcZmHV9WsWNGoCm_85QODA@mail.gmail.com> <CAH+w=7YL25JXUs5aHFtfNvs0WddC-JoDZtv-0+7O1sxkeEaOAg@mail.gmail.com>
On Tue, 10 Sep 2019 at 07:29, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Sep 9, 2019 at 7:21 PM Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> I've been kinda-sorta following this thread amidst a bunch of other
> "real life" distractions. Is the deep meaning here the desire to have
> a $(...) that doesn't fork?
Yes. this was a founding of the idea, but it then did come to me again
when wanting to apply function to array elements.
> parser tokens, so the stuff that follows them can be parsed at the
> statement level rather than gobbled up by the parameter substitution
> code. That is, ideally these two examples --
>
> > - echo ${(x):-REPLY=test2} -> test2
> > ...
>
> -- would be parsed more like $(...) is parsed (and at roughly the same
> place in the parser), so that (among other things) you would not have
> to quote \$val like that.
Would it be hard to accomplish? Because currently the ${...} contents
gets fairly unparsed into stringsubst or paramsubst.
> On the other hand the "var='...'; echo ${(x)var}" example seems
> reasonable and would enable those other two uses as a side-effect.
I also like that method. I think that the need for the quoting would
be natural because of the way :- works. It would even be less natural
to not need to quote.
> I still have a nagging feeling that it should be more like the
> (e^...^) globbing flag, in particular the part about returning arrays
> through reply=(...) but also whether it might look like
> ${(x^code^)var} where "code" would receive the current value of the
> substitution as $REPLY and return the new value in $reply. Your "for"
> example could still I think come out like:
>
> ${(x^eval $REPLY^):-for val (test test3) {
> reply=\$val
> }}
I'm not following the example. Why there's reply= and not reply+=? Why
in the :- it's reply that's altered, while in (x) there's REPLY?
> Other things that need to be thought about before this gets a go/no-go
> are nested substitutions and how to fit (x) into the order-of-events
> subsect(Rules) as laid out in expn.yo.
I think that the (x) flag should be at the top of the list, first.
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author