[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comment on RFE: 'shift'' [N] ARRAYNAME

From: Greg Wooledge
Subject: Re: comment on RFE: 'shift'' [N] ARRAYNAME
Date: Thu, 27 Sep 2018 08:35:51 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Sep 25, 2018 at 05:17:27PM -0700, L A Walsh wrote:
> It struck me as it might be convenient if 'shift' could take an optional
> arrayname as an argument.  Would that be possible or would it cause some
> incompatibility?

The biggest issue here is how you specify the arguments.

Shift already takes one optional argument: the number of items to shift
from the argv list.  Adding a second optional argument leads to a quagmire.
Do you put the optional list name first, or do you put the optional number
first?  If only one argument is given, is it a list name, or is it a number?

(OK, granted, in bash it is not permitted to create an array whose name
is strictly digits, but still.)

If you wish to write an array-shifting builtin, it would be better to give
it a new name.  Don't blindly copy perl.  It's not always the best example
of language design.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]