bug-gawk
[Top][All Lists]
Advanced

[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:56:25 -0500 (CDT)

Andrew J. Schorr wrote:

> I truly do not understand your point. If you
> supply a and d with the same value, it's just
> the same as not supplying d at all. Why is this
> an interesting case? You are free to do it or
> not; it doesn't matter. It should be immediately
> obvious to a thinking programmer that it's a
> silly and pointless usage case. If you think the
> documentation should be enhanced, please supply
> a proposed patch.

I respectfully disagree that it's a pointless use
case.  The destination array argument must be
furnished in order to specify the "how" argument.

If you want the original array sorted in-place, is
asort(a, a, "@val_num_desc") permitted?  Or do you
need to sort to a different destination array and
copy the contents back to a[]?  (I know the answer
(yes, no) in practice, but I don't think it's
unambiguous from the manual.)

Calling asort() without an explicitly named
destination array is (obviously) permitted.  But I
believe the manual does not say that "If you
supply a and d with the same value, it's just the
same as not supplying d at all."  (If I missed
that in the manual, I'm sorry.)  Maybe that
statement is all that's needed.



reply via email to

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