develooper Front page | perl.perl5.porters | Postings from July 2018

Re: [perl #132142] Bleadperl v5.27.3-34-gf6107ca24b breaksMLEHMANN/AnyEvent-HTTP-2.23.tar.gz

Thread Previous | Thread Next
Andreas Koenig
July 5, 2018 19:57
Re: [perl #132142] Bleadperl v5.27.3-34-gf6107ca24b breaksMLEHMANN/AnyEvent-HTTP-2.23.tar.gz
Message ID:
>>>>> On Wed, 27 Jun 2018 01:09:40 -0700, "Dave Mitchell via RT" <> said:

  > On Wed, Jun 27, 2018 at 08:21:43AM +0200, Andreas Koenig wrote:
 >> >>>>> On Mon, 25 Jun 2018 01:15:33 -0700, "Dave Mitchell via RT" <> said:
 >> > On Sun, Jun 24, 2018 at 11:34:30AM +0200, Andreas Koenig wrote:
 >> In your previous posting you asked me "in what way do you feel that the
 >> provided links help in improving fairness". In my response I asked you 4
 >> questions. I would be interesting what your answers to the four
 >> questions are. And why did they not help you to argue it both ways?

 >> Ask yourself what in-place-sort means and answer the following
 >> questions:
 >> - does an in-place-sort change any element within the array?
 >> - is an in-place-sort conceptually an assignment?
 >> - did the as per 2004-02-20 committed solution provide an in-place-sort
 >> disguised as an assignment?
 >> > - was it clever to provide an in-place-sort disguised as an assignement?
 >> My tentative answers:
 >> - no
 >> - no
 >> - yes
 >> - probably not

  > There is ambiguity in the term 'in-place' - it can either refer to
  > something at the user level, or to describe an internal
  > optimisation.

An ambiguity there is, what a great step forward, thank you!

  > If the phrase 'in-place' was being used to describe a user-level feature,
  > then my answers would be:

  >     no
  >     no
  >     no

Could you extend on that? Especially, how big is the difference between
an in-place-sort and the solution provided by the February 2004 commit?

I mean, look how perfectly well allocated the elements of the array are
before and after the sort:

% perl -le 'use Devel::Peek; @a = qw(2 1);Dump @a;@a = sort @a;Dump @a;' 2>&1 | grep at
SV = PVAV(0x561c2532bf08) at 0x561c253493d8
  SV = PV(0x561c2532ada0) at 0x561c2532a1e0
  SV = PV(0x561c2532ae80) at 0x561c2532a3f0
SV = PVAV(0x561c2532bf08) at 0x561c253493d8
  SV = PV(0x561c2532ae80) at 0x561c2532a3f0
  SV = PV(0x561c2532ada0) at 0x561c2532a1e0

Both head and body of every PV involved stay the same. This you can't
get with an ordinary assignment.

  >     no

  > If the phrase 'in-place' was being used to describe the implementation
  > details of an optimisation, then

  >     yes
  >     yes
  >     no
  >     N/A

  > NB I am of the firm opinion that the 2004-02-20 commit was entirely
  > related to the second interpretation.

But let's recall, that there is a finally acknowledged ambiguity for the
reader of the cited thread

  > Here's a question for you. What in the documentation for sort, might lead
  > a reasonable programmer to assume that @a = sort @a is intended behave
  > specially and (amongst other things), not strengthen weak references?

It has already been answered above that it was at least documented in
perl5100delta with this text:

 : =head2 In-place sorting
 : Sorting arrays in place (C<@a = sort @a>) is now optimized to avoid
 : making a temporary copy of the array.

But there is more to it. Documentation is always more than what projects
provide as the manpages. What is being discussed on mailing lists and in
RT tickets is also relevant for the interpretation of the development of
a language. Much more so in 2004 than in 2018 one might add. And finally
Perl is a leading part of the open source culture, which is one of the
reasons we use and love it. So it *may* have happenen that people picked
up partially from discussions and partially from reading the sources.
I'm not saying this is what happened, I don't know. I believe the
discussion in the ticket and the announcement on perl5100delta and some
small experiments with Devel::Peek as I showed above can give a
reasonable picture of the state of the feature.

To sum up: a reasonable perl programmer who was following the
developement on perl5-porters around the time of perl 5.8.4 might have
understood that this in-place sorting was a powerful feature. Readers
who were not reading perl5-porters at that time, can now read the above
linked thread and try to understand how the reasonable programmer might
have taken it up. The reasonable programmer might not have noticed that
the feature did not find its way into the documentation. He might have
used it in a module and uploaded it to CPAN. In fact this did happen


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About