[Top][All Lists]

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

Re: can a and d be the same for asort?

From: Neil R. Ormos
Subject: Re: can a and d be the same for asort?
Date: Mon, 5 Jul 2021 12:55:16 -0500 (CDT)

Wolfgang Laun wrote:
> Peng Yu  wrote:

>> The ambiguity is not defined by the authors. It
>> is defined by the readers.

> Try to find others that see an ambiguity in this
> text, and you might have a case.

I believe there is some ambiguity, or at least
conflict, because of the language that specifies
what happens to the indices of the source and the

| If the optional array dest is specified, then
| source is duplicated into dest. dest is then
| sorted, leaving the indices of source
| unchanged. [...]

| An important side effect of calling asort() is
| that the array's original indices are
| irrevocably lost. As this isn't always
| desirable, asort() accepts a second argument:
| [...]  In this case, gawk copies the source
| array into the dest array and then sorts dest,
| destroying its indices. However, the source
| array is not affected.

If the same array is named as the source and
destination of asort(), are its indices
"unchanged" and "not affected"? Or "irrevocably
lost" and "destroyed"?  Moreover, inasmuch as
asort() is called principally for its side effects
and not its result, is there some other unhappy
interaction between source and destination when
asort(a, a) is called?

I know the answers in practice, but I'm not sure
it's clear from the manual.

I appreciate that Gawk's developer admirably and
generously tries to produce reasonable
user-visible behavior and to protect the user from
bizarre results.

But such protection is not universal, and many
users will have encountered other languages and
library functions that gleefully make a complete
mess when source and destination overlap or are
identical.  Manual readers, and especially those
new to Gawk, should not be expected already to
have synthesized an expectation that Gawk usually
does the reasonable thing.

NOTE: Although I agree that there is some
ambiguity in the manual, I do not endorse the
particular mode of expression used when this issue
was presented and discussed.  The people who
develop Gawk volunteer their time and skilled
effort as a gift to us all.  The principal
maintainer's thoughtful and nearly immediate
responses to credible bug reports is an additional
gift.  (For an opposite experience, try filing a
bug against Firefox.)  If being perceived as a
nicer person isn't enough of a motivation to post
with a little more courtesy and a little less
pugnaciousness, consider self interest.  It would
be a terrible shame if lack of decorum on this
mailing list led the Gawk developers to abandon
their work, so that Gawk became orphaned or was
adopted by other developers who believe the user
is never right, as has happened with some other
Free Software projects.

reply via email to

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