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

[Perl/perl5] 4a04bf: Tests for existing for loop optrees.

Thread Previous
From:
Nicholas Clark via perl5-changes
Date:
October 15, 2021 13:29
Subject:
[Perl/perl5] 4a04bf: Tests for existing for loop optrees.
Message ID:
Perl/perl5/push/refs/heads/smoke-me/nicholas/pp_iter/87815a-4eb638@github.com
  Branch: refs/heads/smoke-me/nicholas/pp_iter
  Home:   https://github.com/Perl/perl5
  Commit: 4a04bf00f0cd3fce8bdd48b0a8898a08c68fae33
      https://github.com/Perl/perl5/commit/4a04bf00f0cd3fce8bdd48b0a8898a08c68fae33
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

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

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


  Commit: 525dc1e45d4c3a81deef4481ad38a8e49380b753
      https://github.com/Perl/perl5/commit/525dc1e45d4c3a81deef4481ad38a8e49380b753
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: c52d5e029a9e8dc660331b57193ea652aa0f2beb
      https://github.com/Perl/perl5/commit/c52d5e029a9e8dc660331b57193ea652aa0f2beb
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: 6ce22ce7e7abeb2ba69129f645e82f16d77fbd89
      https://github.com/Perl/perl5/commit/6ce22ce7e7abeb2ba69129f645e82f16d77fbd89
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: e92ce056f2022a3f96487b1b5a1862a3bf9c159c
      https://github.com/Perl/perl5/commit/e92ce056f2022a3f96487b1b5a1862a3bf9c159c
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: 83c7d349662bf85048f317a6b23155733307f486
      https://github.com/Perl/perl5/commit/83c7d349662bf85048f317a6b23155733307f486
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: c386ecc10be9e73917fa6b819321f0cc47cacdb6
      https://github.com/Perl/perl5/commit/c386ecc10be9e73917fa6b819321f0cc47cacdb6
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: bf6e71ff82686b1287ef59c1565cc669d5301cc5
      https://github.com/Perl/perl5/commit/bf6e71ff82686b1287ef59c1565cc669d5301cc5
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: d9b6ecc18fa9d0af456180eceeef05148bcfdf9f
      https://github.com/Perl/perl5/commit/d9b6ecc18fa9d0af456180eceeef05148bcfdf9f
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: 3b54923c12732530d17e87f548066ceadc63daa4
      https://github.com/Perl/perl5/commit/3b54923c12732530d17e87f548066ceadc63daa4
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

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

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


  Commit: 8f5631846920a7d1c689be27bd3e0da651809cc6
      https://github.com/Perl/perl5/commit/8f5631846920a7d1c689be27bd3e0da651809cc6
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: 2f4c930aab14ce52a5a1ed9b40fac794085453a9
      https://github.com/Perl/perl5/commit/2f4c930aab14ce52a5a1ed9b40fac794085453a9
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M pod/perldelta.pod

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


  Commit: 4d1a422685e560229d927421d45fd2dc84015eee
      https://github.com/Perl/perl5/commit/4d1a422685e560229d927421d45fd2dc84015eee
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M pp_hot.c

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


  Commit: b1ed63167c53cf3d3caefb49adc247668a47c12f
      https://github.com/Perl/perl5/commit/b1ed63167c53cf3d3caefb49adc247668a47c12f
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

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

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


  Commit: ebb7bd1b0e2c6d7fb94fe2cec384474e18ffb4a1
      https://github.com/Perl/perl5/commit/ebb7bd1b0e2c6d7fb94fe2cec384474e18ffb4a1
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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: 4eb63851541cd149fb854155d3664e3814d9583d
      https://github.com/Perl/perl5/commit/4eb63851541cd149fb854155d3664e3814d9583d
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-10-15 (Fri, 15 Oct 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/87815a2e6488...4eb63851541c

Thread Previous


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