Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use a Capture to modify the underlying value in Rakudo #4360

Closed
p6rt opened this issue Jun 28, 2015 · 4 comments
Closed

Can't use a Capture to modify the underlying value in Rakudo #4360

p6rt opened this issue Jun 28, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 28, 2015

Migrated from rt.perl.org#125505 (status was 'resolved')

Searchable as RT125505$

@p6rt
Copy link
Author

p6rt commented Jun 28, 2015

From @masak

<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 :)

@p6rt
Copy link
Author

p6rt commented Jun 29, 2015

From @jnthn

On Sun Jun 28 13​:33​:09 2015, masak wrote​:

<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 :)

Fixed, and tests added to S02-types/capture.t.

@p6rt
Copy link
Author

p6rt commented Jun 29, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt closed this as completed Jun 29, 2015
@p6rt
Copy link
Author

p6rt commented Jun 29, 2015

@jnthn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant