Skip to content

Commit

Permalink
is cached, still experimental. Closes #2550
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jan 17, 2019
1 parent eb1d5d2 commit 0df69d1
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions doc/Type/Routine.pod6
Expand Up @@ -6,14 +6,15 @@
class Routine is Block { }
A C<Routine> is a code object meant for larger unities of code than L<Block|/type/Block>.
Routine is the common superclass for L<Sub|/type/Sub> (and therefore operators) and
L<Method|/type/Method>, the two primary code objects for code reuse.
A C<Routine> is a code object meant for larger unities of code than
L<Block|/type/Block>. Routine is the common superclass for L<Sub|/type/Sub> (and
therefore operators) and L<Method|/type/Method>, the two primary code objects
for code reuse.
Routines serve as a scope limiter for C<return> (i.e. a C<return> returns
from the innermost outer Routine).
Routine is also the level at which
The routine level is also the one at which
L<multiness|/language/glossary#Multi-Dispatch> (multi subs and multi methods)
are handled.
Expand Down Expand Up @@ -127,14 +128,14 @@ Returns C<True> if the routine is a stub
multi sub trait_mod:<is>(Routine $r, :$cached!)
B<NOTE:> this feature is currently EXPERIMENTAL.
Causes the return value of a routine to be stored, so that when subsequent
calls with the same list of arguments are made, the stored value can be
returned immediately instead of re-running the routine.
Causes the return value of a routine to be stored, so that when subsequent calls
with the same list of arguments are made, the stored value can be returned
immediately instead of re-running the routine.N<This is still in experimental
stage. Please check
L<the corresponding section in the experimental features document|/language/experimental#cached>>
Useful when storing and returning the computed value is much faster than
re-computing it every time, and when the time saving trumps the cost of the
re-computing it every time, and when the time saved trumps the cost of the
use of more memory.
Even if the arguments passed to the routine are "reference types" (such as
Expand All @@ -146,6 +147,9 @@ case:
say foo( [1, 2, 3] ); # runs foo
say foo( [1, 2, 3] ); # doesn't run foo, uses cached value
Since it's still at the experimental stage, you will have to insert the C<use
experimental :cached;> statement in any module or script that uses it.
=begin code
use experimental :cached;
Expand Down Expand Up @@ -355,4 +359,4 @@ TODO: explain export tags
=end pod

# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 comments on commit 0df69d1

Please sign in to comment.