# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #112838]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=112838 >


<tadzik> r: my $a = 3; sub transaction { let $a = 7; say "a = $a.
Commiting"; OUTER::<$a> = $a }; transaction(); say $a
<p6eval> rakudo 24ffc9: OUTPUT«a = 7. Commiting␤7␤»
<masak> r: my $a = 3; sub transaction { let $a = 7; say "a = $a.
Commiting" }; transaction(); say $a
<p6eval> rakudo 24ffc9: OUTPUT«a = 7. Commiting␤7␤»
<masak> don't need the OUTER::<$a> thing.
<masak> just make sure not to fail out of that block ;)
<tadzik> huh
<tadzik> okay, I don't get it :)
<masak> that's what "let" does. it's "set this variable to this
value... but if we start backtracking/failing, revert it".
<masak> r: my $a = 42; sub foo { let $a = "this will never stick"; say
$a; fail }; say $a; foo; say $a
<p6eval> rakudo 24ffc9: OUTPUT«42␤this will never stick␤this will never stick␤»
<masak> o.O
* masak submits rakudobug
<tadzik> :>
<masak> my hands are cursed.
<masak> jus' gonna make sure that's how 'let' is actually spec'd.
<masak> S04:179: There is also a C<let> function that sets a
<masak> hypothetical value.  It works exactly like C<temp>, except that the
<masak> value will be restored only if the current block exits unsuccessfully.
<masak> exhibit A.
<masak> S04:1707: In any case, returning an unthrown exception is
considered failure
<masak> from the standpoint of C<let>.
<masak> exhibit B.
<masak> it's a bug.

Reply via email to