3 ms·
Blocks come from smalltalk too: http://web.cecs.pdx.edu/~harry/musings/SmalltalkOverview.html#Blocks http://web.cecs.pdx.edu/~harry/musings/SmalltalkOverview.ht
by gte910h 16y ago
Blocks come from smalltalk too: http://web.cecs.pdx.edu/~harry/musings/SmalltalkOverview.html#Blocks http://web.cecs.pdx.edu/~harry/musings/SmalltalkOverview.htm...
- rtomayko 16y agoUpdated. Thanks!
- flatwhatson 16y agoBlocks 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 :)
- gte910h 16y agoYeah, 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.
- flatwhatson 16y agoI probably should have replied to rtomayko's comment rather than your own. I'd edit the tree, but it's immutable!
- draegtun 16y agoAnd 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");