My other foray into trying to bring functional parity between positional parameters and sequence variables is "shift". I'd like a shift operator that operates on a sequence variable similar to how shift works on positional parameters. Something like perl's shift.
example
a=(foo bar spam)
shift a
now a is (bar spam)
Not sure if I should do this though. It is the equivilent of this not-too-ugly (but not too obvious either)
a=<[ $a[position() > 1] ]>
I am about to implement this (still may) when I realized that the proposed syntax is ambiguous for positional parameters !
ReplyDeletee,g.
shift 1
does that shift the variable $1 or shift $* by 1 ?
Only way to make sense of this is to not allow the syntax to shift positional parameters individually.
That is you can do
shift a
( shifts variable "a")
or
shift 1
( shifts positional parameters $* by 1)
or even
shift a 2
( shifts variable a by 2 )
but there is no syntax to shift $1 by 1 ...
hmm
shift 1 1
? Uglier then sin ?
Implemented in the next release (checked in now to svn)
ReplyDeleteNow in v 0.0.2.5
ReplyDelete