bug-bash
[Top][All Lists]
Advanced

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

Re: setarray[unsetkey] doesn't trigger nounset in arithmetic context


From: Martin D Kealey
Subject: Re: setarray[unsetkey] doesn't trigger nounset in arithmetic context
Date: Mon, 22 May 2023 09:27:17 +1000

I just realised I expressed an opinion about associative arrays while the
original post was about indexed arrays.

My take on this is that indexed arrays are almost always "dynamic"; while
it's possible to use constant indices to emulate a struct, that is unusual.
For most purposes the flexibility in adding & removing from an array is a
feature, not a bug.

The support for missing elements or 'empty slots' is a bit unusual, but
once that's given, it's entirely predictable that "missing" elements are
just a normal kind of data, which is where I was heading with my suggestion
about non-sparse arrays.

On Mon, 22 May 2023 at 07:01, Martin D Kealey <martin@kurahaupo.gen.nz>
wrote:
[...]

> 2. ${#array[@]} gives the number of elements rather than the last index
> (minus 1). Being able to declare an array as non-sparse (so that all gaps
> "exist" with some default value) would fix this.
>

-Martin


reply via email to

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