Use def to declare subs in Perl 6.
Perl6
Latest commit 9b12f5f Oct 26, 2016 @bduggan committed on GitHub Merge pull request #1 from zoffixznet/patch-1
Add mandatory "perl" META field
Permalink
Failed to load latest commit information.
lib/Slang format Jun 28, 2016
t Y combinator example (thx for the idea @bet) Jun 28, 2016
.travis.yml readme Jun 24, 2016
META.info Add mandatory "perl" META field Oct 26, 2016
README.md Y combinator example (thx for the idea @bet) Jun 28, 2016

README.md

Slang::Mosdef

All the cool kids are using def to declare methods. Now you can, too.

Build Status

use Slang::Mosdef;

class Foo {
    def bar {
        say 'I am cool too';
    }
    method baz {
        say 'This is not as much fun';
    }
}

You can also use lambda for subs!

my $yo = lambda { say 'oy' };
$yo();

Or λ!

my $twice = λ ($x) { $x * 2 };
say $twice(0); # still 0

Compute 5 factorial using a Y combinator:

say λ ( &f ) {
  λ ( \n ) {
    return f(&f)(n);
  }
}(
  λ ( &g ) {
    λ ( \n ) {
        return n==1 ?? 1 !! n * g(&g)(n-1);
    }
})(5)