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

Unset and $empty[(i)] and $empty[(I)] -- worth the effort?



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?




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