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

[Perl/perl5] 30e064: Add strict and warnings to t/op/for.t

From:
Nicholas Clark via perl5-changes
Date:
September 16, 2021 09:38
Subject:
[Perl/perl5] 30e064: Add strict and warnings to t/op/for.t
Message ID:
Perl/perl5/push/refs/heads/smoke-me/nicholas/pp_iter/0c36ae-390937@github.com
  Branch: refs/heads/smoke-me/nicholas/pp_iter
  Home:   https://github.com/Perl/perl5
  Commit: 30e064ba88e5304fff83f2b99cb9b2fe6decc975
      https://github.com/Perl/perl5/commit/30e064ba88e5304fff83f2b99cb9b2fe6decc975
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 Sep 2021)

  Changed paths:
    M t/op/for.t

  Log Message:
  -----------
  Add strict and warnings to t/op/for.t

strict subs and refs, but not strict vars, because it's obvious that some
tests are explicitly about package variables, but it's not obvious whether
what they are testing is sensitive to rewriting the variables with full
package names.

Also convert it to done_testing(), and add a call to set_up_inc().


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

  Changed paths:
    M t/op/for.t

  Log Message:
  -----------
  Test that for's iterator aliases the iterated list


  Commit: 78e57cc39595c2a48a499f01c3d05ce69d3a27f0
      https://github.com/Perl/perl5/commit/78e57cc39595c2a48a499f01c3d05ce69d3a27f0
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 Sep 2021)

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

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


  Commit: 290509d8670d91c591332a3409b7c6f3b79e6d01
      https://github.com/Perl/perl5/commit/290509d8670d91c591332a3409b7c6f3b79e6d01
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 56c3f80c4a2d74df27a4ff56d45d9ab45cc76369
      https://github.com/Perl/perl5/commit/56c3f80c4a2d74df27a4ff56d45d9ab45cc76369
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 85e78e7f8a1be6bfce7d089b1a59f6ac544ceda3
      https://github.com/Perl/perl5/commit/85e78e7f8a1be6bfce7d089b1a59f6ac544ceda3
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 5fbfaf24b5852536f06313da67663fe3ff7c1652
      https://github.com/Perl/perl5/commit/5fbfaf24b5852536f06313da67663fe3ff7c1652
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 035866fd04bbf3f3fc5bf023153127f4a0cc7080
      https://github.com/Perl/perl5/commit/035866fd04bbf3f3fc5bf023153127f4a0cc7080
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 997a8c46bb97cc69c1c98f8f04ca43789d77ed4e
      https://github.com/Perl/perl5/commit/997a8c46bb97cc69c1c98f8f04ca43789d77ed4e
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: f4f0d521078c082a302d654af3eac1887761a3ee
      https://github.com/Perl/perl5/commit/f4f0d521078c082a302d654af3eac1887761a3ee
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 918c603bc68fcdb109d66d8e1bdf0615bd6ca025
      https://github.com/Perl/perl5/commit/918c603bc68fcdb109d66d8e1bdf0615bd6ca025
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: ae8de974d4b992a1d83ee659a360008804768b92
      https://github.com/Perl/perl5/commit/ae8de974d4b992a1d83ee659a360008804768b92
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 562b43b655af45910706c94078da04816e678d16
      https://github.com/Perl/perl5/commit/562b43b655af45910706c94078da04816e678d16
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 623f127183bf3d660dbdd66d380a30cd0390bf11
      https://github.com/Perl/perl5/commit/623f127183bf3d660dbdd66d380a30cd0390bf11
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 Sep 2021)

  Changed paths:
    M pod/perldelta.pod

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


  Commit: 7933e5cf970e4ba75211b87f2e931384867994e2
      https://github.com/Perl/perl5/commit/7933e5cf970e4ba75211b87f2e931384867994e2
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 Sep 2021)

  Changed paths:
    M pp_hot.c

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


  Commit: 2900de237eca8858435b8d8871ef5a0a3b4e4c50
      https://github.com/Perl/perl5/commit/2900de237eca8858435b8d8871ef5a0a3b4e4c50
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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: 390937f4796971f94123b325d7c484150be6b04c
      https://github.com/Perl/perl5/commit/390937f4796971f94123b325d7c484150be6b04c
  Author: Nicholas Clark <nick@ccl4.org>
  Date:   2021-09-16 (Thu, 16 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.


Compare: https://github.com/Perl/perl5/compare/0c36ae8bb751...390937f47969



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