Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Naively implement "is cached" on Routines
  • Loading branch information
lizmat committed Apr 13, 2014
1 parent c855a0f commit 442cdf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/core/Routine.pm
Expand Up @@ -129,4 +129,14 @@ my class Routine { # declared in BOOTSTRAP
method package() { $!package }
}

multi sub trait_mod:<is>(Routine $r, :$cached!) {
my %cache;
$r.wrap(-> |c {
my $WHICH := c.WHICH;
%cache{$WHICH}:exists
?? %cache{$WHICH}
!! (%cache{$WHICH} = callsame);
});
}

# vim: ft=perl6 expandtab sw=4
10 changes: 0 additions & 10 deletions src/core/core_epilogue.pm
Expand Up @@ -14,16 +14,6 @@ BEGIN {
Perl6::Metamodel::GrammarHOW.HOW.compose(Perl6::Metamodel::GrammarHOW);
}

multi sub trait_mod:<is>(Routine $r, :$cached!) {
my %cache;
$r.wrap(-> |c {
my $WHICH := c.WHICH;
%cache{$WHICH}:exists
?? %cache{$WHICH}
!! (%cache{$WHICH} = callsame);
});
}

{YOU_ARE_HERE}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 442cdf8

Please sign in to comment.