News for hackers. Stuff that matters.
Re:Perl 11 by CydeWeys on Wednesday October 24, 2018 @04:53AM (#18290748)
Also, in languages like Java, C++, or C#, you can use bare braces to define a new scope, no keyword necessary. It's not done so much anymore because modern coding standards tend to favor shorter functions for clarity and unit testability, but it's always still an option.
Re:Perl 11 by mst on Wednesday October 24, 2018 @05:08AM (#18290815)
You can do bare braces in perl5 too, I used the 'do { ... }' block because that's an expression rather than a statement so I could return the subroutine -

  my $code;
  {
    my $count = 0;
    $code = sub { ++$count };
  }
would've been equivalent but I always try and do assign-once-at-declaration-time where possible because mutable state is my mortal enemy.