# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #125505] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=125505 >
<jaffa4> I How can I make a reference to scalar? <masak> m: my $scalar = 42; my $ref = \$scalar; $scalar++; say $ref <camelia> rakudo-moar 367b58: OUTPUT«\(43)» <jaffa4> masak: is it not that capture? <masak> jaffa4: yes, that is a capture. when someone asks about "taking a reference" in Perl 6, I think about captures. <jaffa4> masak : there is a problem with that reference... cannot change variable value <jnthn> A Capture can be indexed positionally to get the things in it <jnthn> m: my $a = 41; my $b = \($a); $b[0]++; say $a <camelia> rakudo-moar 367b58: OUTPUT«Cannot assign to an immutable value [...] <jnthn> ah <jnthn> But yeah, the usual way to do such things these days is "is rw" parameters and so on <Ben_Goldberg> m: my $scalar = 42; my $ref = \$scalar; { ++$_ }( |$ref ); say $scalar; <camelia> rakudo-moar 367b58: OUTPUT«43» <jaffa4> jnthn: so is it a bug? <jnthn> That you can't ++ the [0]'d thing maybe is * masak submits rakudobug <jnthn> masak: Thanks, I'm just a bit too tired to fix that now, but can easily do it in the morning :)