6
6
7
7
class Routine is Block { }
8
8
9
- A C < Routine > is a code object meant for larger unities of code than L < Block|/type/Block > .
10
- Routine is the common superclass for L < Sub|/type/Sub > (and therefore operators) and
11
- L < Method|/type/Method > , the two primary code objects for code reuse.
9
+ A C < Routine > is a code object meant for larger unities of code than
10
+ L < Block|/type/Block > . Routine is the common superclass for L < Sub|/type/Sub > (and
11
+ therefore operators) and L < Method|/type/Method > , the two primary code objects
12
+ for code reuse.
12
13
13
14
Routines serve as a scope limiter for C < return > (i.e. a C < return > returns
14
15
from the innermost outer Routine).
15
16
16
- Routine is also the level at which
17
+ The routine level is also the one at which
17
18
L < multiness|/language/glossary#Multi-Dispatch > (multi subs and multi methods)
18
19
are handled.
19
20
@@ -127,14 +128,14 @@ Returns C<True> if the routine is a stub
127
128
128
129
multi sub trait_mod:<is>(Routine $r, :$cached!)
129
130
130
- B < NOTE: > this feature is currently EXPERIMENTAL.
131
-
132
- Causes the return value of a routine to be stored, so that when subsequent
133
- calls with the same list of arguments are made, the stored value can be
134
- returned immediately instead of re-running the routine.
131
+ Causes the return value of a routine to be stored, so that when subsequent calls
132
+ with the same list of arguments are made, the stored value can be returned
133
+ immediately instead of re-running the routine. N < This is still in experimental
134
+ stage. Please check
135
+ L < the corresponding section in the experimental features document|/language/experimental#cached > >
135
136
136
137
Useful when storing and returning the computed value is much faster than
137
- re-computing it every time, and when the time saving trumps the cost of the
138
+ re-computing it every time, and when the time saved trumps the cost of the
138
139
use of more memory.
139
140
140
141
Even if the arguments passed to the routine are "reference types" (such as
@@ -146,6 +147,9 @@ case:
146
147
say foo( [1, 2, 3] ); # runs foo
147
148
say foo( [1, 2, 3] ); # doesn't run foo, uses cached value
148
149
150
+ Since it's still at the experimental stage, you will have to insert the C < use
151
+ experimental :cached; > statement in any module or script that uses it.
152
+
149
153
= begin code
150
154
use experimental :cached;
151
155
@@ -355,4 +359,4 @@ TODO: explain export tags
355
359
356
360
= end pod
357
361
358
- # vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
362
+ # vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
0 commit comments