Groups | Search | Server Info | Login | Register
Groups > alt.comp.lang.awk > #18
| Path | csiph.com!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail |
|---|---|
| From | gazelle@shell.xmission.com (Kenny McCormack) |
| Newsgroups | alt.comp.lang.awk, comp.lang.awk |
| Subject | Array indices are small integers? (Was: printing words without newlines?) |
| Date | Tue, 14 May 2024 13:40:21 -0000 (UTC) |
| Organization | The official candy of the new Millennium |
| Message-ID | <v1vpk5$vbji$1@news.xmission.com> (permalink) |
| References | <v1pi7c$2b87j$1@dont-email.me> <20240513100418.652@kylheku.com> <v1tih0$u8kt$1@news.xmission.com> <20240513162301.128@kylheku.com> |
| Injection-Date | Tue, 14 May 2024 13:40:21 -0000 (UTC) |
| Injection-Info | news.xmission.com; posting-host="shell.xmission.com:166.70.8.4"; logging-data="1027698"; mail-complaints-to="abuse@xmission.com" |
| X-Newsreader | trn 4.0-test77 (Sep 1, 2010) |
| Originator | gazelle@shell.xmission.com (Kenny McCormack) |
| Xref | csiph.com alt.comp.lang.awk:18 comp.lang.awk:9741 |
Cross-posted to 2 groups.
Show key headers only | View raw
In article <20240513162301.128@kylheku.com>,
Kaz Kylheku <643-408-1753@kylheku.com> wrote:
...
>> Final note: In fact, it has been established (on this newsgroup as well as
>> empirically by me and others) that if the indices are small integers, you
>> get sorting for free (in GAWK, which, as noted, is all we care about). So,
>> you don't even really need to mess with PROCINFO[]...
>
>Are you referring to the idea of just replacing the above for + if
>structure with:
>
> for (i in rank) {
>
> }
>
>and relying on the small integer indices being hashed in order?
Yes.
>Where is that documented? The manual reiterates that this is not
>specified: "By default, the order in which a for (indx in array) loop
>scans an array is not defined; it is generally based upon the internal
>implementation of arrays inside awk."
It is documented in this newsgroup (Google is your friend).
And assented to by one or both of the GAWK insiders who are known to post here.
It seems to be an attribute (i.e., quirk) of the particular hashing
algorithm used.
Now, of course it isn't guaranteed and could disappear in some future
version of GAWK - and, of course, one wouldn't rely on it in production
code, since it is so easy to make it right by including the line (shown in
this thread's OP) that sets PROCINFO[].
But it is true, nonetheless.
--
The key difference between faith and science is that in science, evidence that
doesn't fit the theory tends to weaken the theory (that is, make it less likely to
be believed), whereas in faith, contrary evidence just makes faith stronger (on
the assumption that Satan is testing you - trying to make you abandon your faith).
Back to alt.comp.lang.awk | Previous | Next — Previous in thread | Next in thread | Find similar
printing words without newlines? David Chmelik <dchmelik@gmail.com> - 2024-05-12 04:57 +0000
Re: printing words without newlines? Bruce Horrocks <07.013@scorecrow.com> - 2024-05-12 09:52 +0100
Re: printing words without newlines? Bruce Horrocks <07.013@scorecrow.com> - 2024-05-12 09:55 +0100
Re: printing words without newlines? gazelle@shell.xmission.com (Kenny McCormack) - 2024-05-12 12:11 +0000
Re: printing words without newlines? David Chmelik <dchmelik@gmail.com> - 2024-05-13 02:04 +0000
Re: printing words without newlines? Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-13 16:49 +0000
Re: printing words without newlines? gazelle@shell.xmission.com (Kenny McCormack) - 2024-05-13 06:56 +0000
Re: printing words without newlines? gazelle@shell.xmission.com (Kenny McCormack) - 2024-05-13 14:53 +0000
Resurrecting an old thread (Was: printing words without newlines?) gazelle@shell.xmission.com (Kenny McCormack) - 2024-07-15 18:10 +0000
Re: printing words without newlines? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-13 10:18 +0200
Re: printing words without newlines? Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-13 17:17 +0000
Re: printing words without newlines? gazelle@shell.xmission.com (Kenny McCormack) - 2024-05-13 17:26 +0000
Re: printing words without newlines? Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-13 23:33 +0000
Array indices are small integers? (Was: printing words without newlines?) gazelle@shell.xmission.com (Kenny McCormack) - 2024-05-14 13:40 +0000
Re: printing words without newlines? Ed Morton <mortonspam@gmail.com> - 2024-05-16 08:11 -0500
Re: printing words without newlines? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-16 15:55 +0200
Once upon a time... (Was: printing words without newlines?) gazelle@shell.xmission.com (Kenny McCormack) - 2024-05-16 14:15 +0000
Re: Once upon a time... (Was: printing words without newlines?) gazelle@shell.xmission.com (Kenny McCormack) - 2024-05-16 15:17 +0000
Re: printing words without newlines? Ed Morton <mortonspam@gmail.com> - 2024-05-16 19:40 -0500
csiph-web