zsh-workers
 help / color / mirror / Atom feed
* Unset and $empty[(i)] and $empty[(I)] -- worth the effort?
@ 2020-12-07 23:13 Bart Schaefer
  2020-12-23 23:04 ` Felipe Contreras
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2020-12-07 23:13 UTC (permalink / raw)
  To: Zsh hackers list

Current behavior (git master branch):

5.8.0.2-dev % print $notset[(i)] $notset[(I)]

5.8.0.2-dev % typeset emptystr
5.8.0.2-dev % print $emptystr[(i)] $emptystr[(I)]
0 0
5.8.0.2-dev % typeset -a emptyarr
5.8.0.2-dev % print $emptyarr[(i)] $emptyarr[(I)]
1 0
5.8.0.2-dev % unset emptyarr
5.8.0.2-dev % print $emptyarr[(i)] $emptyarr[(I)]

5.8.0.2-dev %

I want to rationalize $emptystr[(i)] by saying that it's searching for
an empty substring and it did find one, so it can't return
(($#emptystr + 1)), but there's not really a $emptystr[0] either.  In
the reverse direction, if an empty stubstring is allowed to match
there's no unambiguous answer for $emptystr[(I)].

Behavior on the declarednull branch:

delclarednull % print $notset[(i)] $notset[(I)]

delclarednull % typeset emptystr
delclarednull % print $emptystr[(i)] $emptystr[(I)]

delclarednull % emptystr=""
delclarednull % print $emptystr[(i)] $emptystr[(I)]
0 0
delclarednull % typeset -a emptyarr
delclarednull % print $emptyarr[(i)] $emptyarr[(I)]

delclarednull % emptyarr=()
delclarednull % print $emptyarr[(i)] $emptyarr[(I)]
1 0
delclarednull % unset emptyarr
delclarednull % print $emptyarr[(i)] $emptyarr[(I)]

delclarednull %

Given that the behavior on $emptystr is already poorly defined, I'm
not sure it makes much sense to put any effort into making the
uninitialized $emptyarr case differ from the $notset case.

Further opinions?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unset and $empty[(i)] and $empty[(I)] -- worth the effort?
  2020-12-07 23:13 Unset and $empty[(i)] and $empty[(I)] -- worth the effort? Bart Schaefer
@ 2020-12-23 23:04 ` Felipe Contreras
  2020-12-24 19:06   ` Phil Pennock
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Contreras @ 2020-12-23 23:04 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

On Mon, Dec 7, 2020 at 5:13 PM Bart Schaefer <schaefer@brasslantern.com> wrote:

> Given that the behavior on $emptystr is already poorly defined, I'm
> not sure it makes much sense to put any effort into making the
> uninitialized $emptyarr case differ from the $notset case.

True. I misunderstood what $arr[(i|I)] did, and I can't find any
documentation about them.

But given what I can gather from the tests, it probably is not a
use-case that anybody would care deeply about, ever. If it turns out
somebody does, that can be fixed later.

That's my two cents.

Cheers.

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unset and $empty[(i)] and $empty[(I)] -- worth the effort?
  2020-12-23 23:04 ` Felipe Contreras
@ 2020-12-24 19:06   ` Phil Pennock
  2020-12-29 17:54     ` Felipe Contreras
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Pennock @ 2020-12-24 19:06 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Zsh hackers list

On 2020-12-23 at 17:04 -0600, Felipe Contreras wrote:
> True. I misunderstood what $arr[(i|I)] did, and I can't find any
> documentation about them.

zshparam(1), "Subscript Flags".

It's sometimes a little confusing that most of the expansion flags are
in zshexpn(1), except these.

-Phil


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unset and $empty[(i)] and $empty[(I)] -- worth the effort?
  2020-12-24 19:06   ` Phil Pennock
@ 2020-12-29 17:54     ` Felipe Contreras
  0 siblings, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2020-12-29 17:54 UTC (permalink / raw)
  To: Phil Pennock; +Cc: Zsh hackers list

On Thu, Dec 24, 2020 at 1:06 PM Phil Pennock
<zsh-workers+phil.pennock@spodhuis.org> wrote:
>
> On 2020-12-23 at 17:04 -0600, Felipe Contreras wrote:
> > True. I misunderstood what $arr[(i|I)] did, and I can't find any
> > documentation about them.
>
> zshparam(1), "Subscript Flags".
>
> It's sometimes a little confusing that most of the expansion flags are
> in zshexpn(1), except these.

Ahh, I see. Thank you.

-- 
Felipe Contreras


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-29 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 23:13 Unset and $empty[(i)] and $empty[(I)] -- worth the effort? Bart Schaefer
2020-12-23 23:04 ` Felipe Contreras
2020-12-24 19:06   ` Phil Pennock
2020-12-29 17:54     ` Felipe Contreras

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git