Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16280
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?) |
| Date | 2020-05-04 16:16 -0400 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.2092.1588623373.3066.bug-bash@gnu.org> (permalink) |
| References | (7 earlier) <CALv3B7YTnS8R8D=dYbbOUFROOvhSQ1gfc_ETT+cikp3onBMR1A@mail.gmail.com> <61c51c64-d17e-6ea0-6ace-0c3365ef2299@case.edu> <CALv3B7Yrg7bDO0eViSTBWad56vw_dGnnXtMRa9ofYysiAiYJbA@mail.gmail.com> <20200420215025.GZ845@eeg.ccf.org> <326de0f1-f0af-2398-02ae-d200861c38f4@case.edu> |
On 4/20/20 5:50 PM, Greg Wooledge wrote: > On Mon, Apr 20, 2020 at 05:12:28PM -0400, George Jones wrote: >> No real opinion on syntax. >> >> Using something existing: >> >> declare -A foo[SIZE] >> >> seems sensible, especially if there was no semantic meaning (I'm not a fan >> of syntax without semantics .... clutter). > > That's pretty C-like, and I don't have any strong dislike of it, but I > feel I should point out that users will need to quote the final argument > if it contains square brackets, just like with unset 'a[i]'. If the code to skip over it didn't already exist, I wouldn't consider it. > Another choice would be a more shell-like syntax: > > declare -s size -A foo=(...) That's definitely more consistent with the rest of declare's options. > I'm curious whether the size has to be specified up front when the array > is declared, or can be adjusted on the fly. It could be adjusted on the fly, I suppose, but there would never really be a reason to do it unless the size were being reduced. Otherwise, it's ok to just let the array grow automatically. > The shell-like syntax feels > more natural if the size is being adjusted, since you can write > > declare -s new_size foo > > without needing to specify the -A again. But it's not a huge difference. This is a good point. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: [PATCH] Implement rehashing for associative arrays (Re: speeding up hash_search?) Chet Ramey <chet.ramey@case.edu> - 2020-05-04 16:16 -0400
csiph-web