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

Re: Empty element elision and associative arrays (was Re: Slurping a file)



On Thu, Jan 18, 2024 at 12:22 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
Seems to me to be the sort of thing that can't possibly have any gotchas.

I'm not saying it would introduce gotchas. I don't think anyone's writing code that would break if assoc arrays were suddenly sorted. :)

I'm saying that if zsh changed to keep its associative arrays in sorted order, and then you wrote a zsh program that relied on that behavior, you'd have a backward compatibility problem: your new script wouldn't work properly in older versions of zsh that didn't have the sorting. If you wanted your script to behave consistently even when run on such versions, you'd have to write manual code to keep the ordering, separately from the array itself. You could pair that with a check of $ZSH_VERSION and only do the manual bit when not running a version that does it for you automatically, but unless you're happy to cut out backward compatibility entirely, you'd still have to write it.

And if you'd have to write it anyway, you might as well just use it unconditionally and avoid the complexity of switching code in and out based on the version.

That's all I was saying.  It wasn't much of a point, and probably didn't warrant three messages clarifying it. :)

--
Mark J. Reed <markjreed@xxxxxxxxx>


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