← Back to context

Comment by mst

11 days ago

Yep, with exactly the same semantics as perl5's 25+ years old 'my' -

  foreach my $x (@input) {
    push @callbacks, sub { $x };
  }

works how you'd expect.

I was spoiled by this and driven nuts by function level scoping like python's and javascript's 'var', and the adoption of 'let' made me very happy.

My current annoyance with JS is its lack of -

  my $foo = do {
    ...;
    ...;
    <expression>
  };

but there's a proposal for that, and the 'match' proposal (which would be glorious) depends on it on the basis it's a shoo-in, so I am very hopeful.

Note that I know:

  let foo; {
    ...;
    ...;
    foo = <expression>
  }

already works but it's Not The Same (although significantly less upsetting than (() => { ... })() is ;).