Hacker News new | past | comments | ask | show | jobs | submit login

Blocks are also available in Perl, in the form of anonymous subroutines. They follow Perlish conventions for argument handling (rather than having a neat inline syntax like Smalltalk or Ruby), but they're most definitely the same thing!

  my $block   = sub {             say "w00t, blocks!"   };
  my $closure = sub { $block->(); say "w00t, closures!" };
You'll have to look further for something Ruby does that Perl doesn't :)



And in Perl6 you can drop the sub bit:

    my $block = { say "w00t, blocks!" };
And there are also pointy blocks for neater stuff:

    my $pointy_block = -> $text { say "$text, blocks" };
    $pointy_block("ne@t");


Yeah, smalltalk blocks are almost identical to ruby blocks.

Article just acted like that was a ruby invention (which they corrected)

My comment had nothing to do with perl.


I probably should have replied to rtomayko's comment rather than your own. I'd edit the tree, but it's immutable!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: