develooper Front page | perl.perl5.changes | Postings from September 2021

[Perl/perl5] 19f8a8: Tests for existing for loop optrees.

From:
Nicholas Clark via perl5-changes
Date:
September 22, 2021 12:28
Subject:
[Perl/perl5] 19f8a8: Tests for existing for loop optrees.
Message ID:
Perl/perl5/push/refs/heads/smoke-me/nicholas/pp_iter/36df89-87815a@github.com
  Branch: refs/heads/smoke-me/nicholas/pp_iter
  Home:   https://github.com/Perl/perl5
  Commit: 19f8a84a981e4d719259da9ccbe97fae32cb2cc0
      https://github.com/Perl/perl5/commit/19f8a84a981e4d719259da9ccbe97fae32cb2cc0
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M MANIFEST
    A ext/B/t/optree_for.t

  Log Message:
  -----------
  Tests for existing for loop optrees.


  Commit: 18de4ac32db8ac4decce7033e43893a69d3e8d0d
      https://github.com/Perl/perl5/commit/18de4ac32db8ac4decce7033e43893a69d3e8d0d
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M pp_hot.c

  Log Message:
  -----------
  Re-indent the case statement in pp_iter, ready for the next commit.

Add braces and indent a block that will become a `for` loop in the next
commit. With the exception of these and merging 3 opening braces onto the
`if` or `else` on the previous lines, this commit is purely a whitespace
change.


  Commit: 6b6a68693841a7728564eb9b2e596655791df4e1
      https://github.com/Perl/perl5/commit/6b6a68693841a7728564eb9b2e596655791df4e1
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M pp_hot.c

  Log Message:
  -----------
  Iterate for loops $n-at-a-time in PP_ITER.

This commit provides the runtime changes needed to iterate for loops over
two or more variables.


  Commit: 7a1075c02dfa41c0cdced63876c0c61e60997e7f
      https://github.com/Perl/perl5/commit/7a1075c02dfa41c0cdced63876c0c61e60997e7f
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M op.c
    M pod/perldiag.pod

  Log Message:
  -----------
  Generate the optree for n-at-a-time for loops.

Perl_newFOROP can now also take an OP_LIST corresponding to two or more
lexicals to iterate over n-at-a-time, where those lexicals are all
declared in the for statement, and occupy consecutive pad slots.


  Commit: a70121cbb72661bddfc49651b3647f587fa6c5f8
      https://github.com/Perl/perl5/commit/a70121cbb72661bddfc49651b3647f587fa6c5f8
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M perly.act
    M perly.h
    M perly.tab
    M perly.y
    M toke.c

  Log Message:
  -----------
  Implement n-at-a-time for loops.

For example, this now works:

    for my ($key, $value) (%hash) { ... }

Only for scalars declared with my as a list in the for loop statement.
As many as you want (unless you want more than 4294967296).


  Commit: 9d2c0782a91800b1b376f9cb265e199d431d27b1
      https://github.com/Perl/perl5/commit/9d2c0782a91800b1b376f9cb265e199d431d27b1
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M MANIFEST
    M pod/perlsyn.pod
    A t/op/for-many.t

  Log Message:
  -----------
  Regression tests and documentation for n-at-a-time for.


  Commit: 803bb8019260faf7bfa9c37656abd3c17c27c567
      https://github.com/Perl/perl5/commit/803bb8019260faf7bfa9c37656abd3c17c27c567
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M ext/B/B/Concise.pm
    M ext/B/t/optree_for.t

  Log Message:
  -----------
  B::Concise now handles n-at-a-time for.


  Commit: 8b7aa8e4305788f70f89b55541ae664e8ecb17e0
      https://github.com/Perl/perl5/commit/8b7aa8e4305788f70f89b55541ae664e8ecb17e0
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M lib/B/Deparse.pm
    M lib/B/Deparse.t

  Log Message:
  -----------
  B::Deparse now handles n-at-a-time for.


  Commit: 03f1430182196bf2dccb88560e248e784edecc88
      https://github.com/Perl/perl5/commit/03f1430182196bf2dccb88560e248e784edecc88
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M pp_hot.c

  Log Message:
  -----------
  Move reading CxTYPE(cx) out of the loop, to be clear that it doesn't change.

Move some other variable declarations into a tighter scope, and initialise
variables at the point of declaration where possible.

With the recent changes, the function consists of a 4-way switch inside a
loop, where each iteration of the loop will take the same case in the
switch. This implies a branch taken on each iteration of the loop, which
is less efficient than the alternative structure of taking the branch once
and then looping.

However, the way the code is structured (particularly how two of the cases
share code, by jumping sideways), means that rewriting it to "switch first"
structure would not be clearer (and likely would also be hard to get
right). Hence it seems better to let a compiler optimiser choose what is
best. However, it might not realise that CxTYPE(cx) won't be changed, even
as a side effect of any function called by this code. Hence hoist it into a
constant variable to make this unequivocal.


  Commit: a83a89cb1dca0b64dd5d4e7e327032289548b2e6
      https://github.com/Perl/perl5/commit/a83a89cb1dca0b64dd5d4e7e327032289548b2e6
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M lib/warnings.pm
    M regen/warnings.pl
    M warnings.h

  Log Message:
  -----------
  Add a new warning experimental::for_list.


  Commit: 6603573cc81f33ef56c2f264fb9998f035c372a2
      https://github.com/Perl/perl5/commit/6603573cc81f33ef56c2f264fb9998f035c372a2
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M lib/B/Deparse.t
    M pod/perldiag.pod
    M pod/perlsyn.pod
    M t/op/for-many.t
    M toke.c

  Log Message:
  -----------
  n-at-a-time for loops now warn by default (as 'experimental::for_list').


  Commit: c8bca2d89da95365b2922bddffdb305037843172
      https://github.com/Perl/perl5/commit/c8bca2d89da95365b2922bddffdb305037843172
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M pod/perldelta.pod

  Log Message:
  -----------
  perldelta for n-at-a-time for loops.


  Commit: e6e72fcdf995ac87d4fca28fcca53931cb07f890
      https://github.com/Perl/perl5/commit/e6e72fcdf995ac87d4fca28fcca53931cb07f890
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M pp_hot.c

  Log Message:
  -----------
  Note why this if block in pp_iter is empty


  Commit: 74eaaeb89e59edae007e7788ed41a1d63e078473
      https://github.com/Perl/perl5/commit/74eaaeb89e59edae007e7788ed41a1d63e078473
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M t/op/for-many.t

  Log Message:
  -----------
  Test next, continue and redo with n-at-a-time for loops


  Commit: b6bb68d65f4deec8f04cfde91377019d92a2c199
      https://github.com/Perl/perl5/commit/b6bb68d65f4deec8f04cfde91377019d92a2c199
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M perly.act
    M perly.h
    M perly.tab
    M perly.y
    M t/op/for-many.t

  Log Message:
  -----------
  for my ($foo,,, $bar) { ... } should parse as ($foo, $bar)

Multiple commas between the lexicals in the list shouldn't change the
parsing.


  Commit: 87815a2e6488a5acb0084703ed3ec2f7b5f807b3
      https://github.com/Perl/perl5/commit/87815a2e6488a5acb0084703ed3ec2f7b5f807b3
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M pod/perldelta.pod
    M pod/perldiag.pod
    M pod/perlsyn.pod

  Log Message:
  -----------
  Pod improvements suggested by Matthew Horsfall


Compare: https://github.com/Perl/perl5/compare/36df89b01071...87815a2e6488



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About