Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: array slice
On Jun 26, 2:51pm, Peter Stephenson wrote:
}
} It looks like half closing your eyes, sticking your fingers in your
} ears, and copying what's there already does the trick.
Very good! Just a couple of notes ...
This error message looks odd:
torch% typeset y[2,4]=(x)
typeset: y[2,4]: can't create local array elements
I guess that isn't new, but to refer to "local" at top-level prompt is
funny. "(on & PM_LOCAL)" is evidently true even though the typeset is
not within function scope. Amusingly it works to simply force the
variable to be global:
torch% typeset -g y[2,4]=(x)
torch% typeset -p y
typeset -a y
y=('' x)
And an array is always created for this, even without the parens:
torch% typeset -g z[2,4]=y
torch% typeset -p z
typeset -a z
z=('' y)
Lastly, handling slices still doesn't fix the empty array assignment:
torch% typeset x=() x[1]=1 x[3]=3
torch% typeset -p x
typeset -a x
x=(1 '' 3)
torch% typeset x=() x[2]=b x[4]=d
torch% typeset -p x
typeset -a x
x=(1 b 3 d)
torch% typeset x[2]=2 x[4]=4 x=()
torch% typeset -p x
typeset -a x
x=(1 2 3 4)
Although this works:
torch% typeset x[1,-1]=()
torch% typeset -p x
typeset -a x
x=()
torch% typeset x[2]=b x[4]=d x[1,3]=()
torch% typeset -p x
typeset -a x
x=(d)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author