File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1195,6 +1195,33 @@ You can also assign immediately as part of the call to temp:
1195
1195
temp $a = "five";
1196
1196
= end code
1197
1197
1198
+ Be warned the C < temp > effects get removed once the block is left. If
1199
+ you were to access the value from, say, within a L < Promise > after
1200
+ the C < temp > was undone, you'd get the original value, not the C < temp > one:
1201
+
1202
+ = begin code
1203
+ my $v = "original";
1204
+ {
1205
+ temp $v = "new one";
1206
+ start {
1207
+ say "[PROMISE] Value before block is left: `$v`";
1208
+ sleep 1;
1209
+ say "[PROMISE] Block was left while we slept; value is now `$v`";
1210
+ }
1211
+ sleep ½;
1212
+ say "About to leave the block; value is `$v`";
1213
+ }
1214
+ say "Left the block; value is now `$v`";
1215
+ sleep 2;
1216
+
1217
+ # OUTPUT:
1218
+ # [PROMISE] Value before block is left: `new one`
1219
+ # About to leave the block; value is `new one`
1220
+ # Left the block; value is now `original`
1221
+ # [PROMISE] Block was left while we slept; value is now `original`
1222
+ = end code
1223
+
1224
+
1198
1225
= head2 prefix C « let »
1199
1226
1200
1227
sub prefix:<let>(Mu $a is rw)
You can’t perform that action at this time.
0 commit comments