Skip to content

Commit b44666b

Browse files
committed
Correction of how temp inits a variable.
Move the comparison to p5 (which was inline on temp) instead to local in the p5 section. Fixes #1085
1 parent 7b663ba commit b44666b

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

doc/Language/5to6-perlfunc.pod6

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,9 @@ you would call on some variety of IO::Socket object.
722722
723723
=item local EXPR
724724
725-
The Perl 6 equivalent is C<temp>.
725+
The Perl 6 equivalent is C<temp>. Unlike C<local>, however, the value of
726+
the given variable is not immediately unset: it retains its original value
727+
until assigned to.
726728
727729
=head2 localtime
728730

doc/Language/operators.pod6

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,17 +1172,25 @@ details.
11721172
sub prefix:<temp>(Mu $a is rw)
11731173
=end code
11741174
1175-
"temporizes" the variable passed as the argument, which means it is reset
1176-
to its old value on scope exit. For example:
1175+
"temporizes" the variable passed as the argument. The variable begins
1176+
with the same value as it had in the outer scope, but can be assigned
1177+
new values in this scope. Upon exiting the scope, the variable will be
1178+
restored to its original value.
11771179
11781180
my $a = "three";
11791181
say $a; # three
11801182
{
1181-
temp $a = "four";
1183+
temp $a;
1184+
say $a; # three
1185+
$a = "four";
11821186
say $a; # four
11831187
}
11841188
say $a; # three
11851189
1190+
Note that you can also assign immediately as part of the call to temp:
1191+
1192+
temp $a = "five";
1193+
11861194
=head2 prefix C«let»
11871195
11881196
=begin code :skip-test

0 commit comments

Comments
 (0)