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

hyperop'd -= won't DWIM a single element on the right #3789

Closed
p6rt opened this issue Apr 18, 2015 · 5 comments
Closed

hyperop'd -= won't DWIM a single element on the right #3789

p6rt opened this issue Apr 18, 2015 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Apr 18, 2015

Migrated from rt.perl.org#124331 (status was 'rejected')

Searchable as RT124331$

@p6rt
Copy link
Author

p6rt commented Apr 18, 2015

From @timo

This code​:

  my @​sizes = 100, 110, 120, 130; @​sizes >>-=>> @​sizes[0]; say @​sizes

gives 0, 110, 120, 130.

  my @​sizes = 100, 110, 120, 130; @​sizes = @​sizes >>-=>> (@​sizes[0] xx
4); say @​sizes

gives 0, 10, 20, 30 (which is what I expect the other one to work, too).

  my @​sizes = 100, 110, 120, 130; @​sizes >>-=>> (@​sizes[0] xx 4); say
@​sizes

gives the expected result, too.

@p6rt
Copy link
Author

p6rt commented Apr 25, 2015

From @peschwa

On Sat Apr 18 02​:37​:01 2015, timo wrote​:

This code​:

my @​sizes = 100, 110, 120, 130; @​sizes >>\-=>> @​sizes\[0\]; say @​sizes

gives 0, 110, 120, 130.

my @​sizes = 100, 110, 120, 130; @​sizes = @​sizes >>\-=>> \(@​sizes\[0\] xx

4); say @​sizes

gives 0, 10, 20, 30 (which is what I expect the other one to work, too).

my @​sizes = 100, 110, 120, 130; @​sizes >>\-=>> \(@​sizes\[0\] xx 4\); say

@​sizes

gives the expected result, too.

23​:25 < psch> timotimo​: i talked to you about that 2 or 3 days ago
23​:25 < timotimo> it coul dbe related to not sinking the hyperop so it's not doing anything? but hyper is supposed to be hyper, not lazy
23​:25 < psch> timotimo​: my understanding is that the RHS doesn't get thunked and thus you're substracting 0
23​:25 < psch> for elems 1 to 3
23​:25 < psch> m​: my @​sizes = 100, 110, 120, 130; @​sizes >>+=>> @​sizes[0]; say @​sizes # easier to see with +
23​:26 <+camelia> rakudo-moar 40a424​: OUTPUT«200 310 320 330␤»
23​:26 < psch> m​: my @​sizes = 100, 110, 120, 130; @​sizes >>+=>> @​sizes[0]<>; say @​sizes # for comparison
23​:26 <+camelia> rakudo-moar 40a424​: OUTPUT«200 210 220 230␤»
23​:26 < psch> or maybe "doesn't get thunked" is a bit wrong here
23​:26 < psch> the array elem container gets thunked, the contents don't, if that makes sense
23​:27 < psch> (might also have been more than 2 or 3 days ago, i'm not quite sure)
23​:28 < psch> read that as "i can rationalize why it happens like it does", not as "i think it should happen as it does" though :)
23​:29 < psch> i'm not really sure what i think should happen there; on the one hand it makes sense not to have to do anything special, but what if i want to use the container and not the value?
23​:29 < psch> and on the other hand, it's the first actual use for <> (or .decont or zen slice or w/e) aside from Str interpolation that i came across
23​:31 < psch> timotimo​: does that make any sense to you?
23​:53 < timotimo> um
23​:53 < timotimo> the right hand side doesn't need to be th... ooooooooh!
23​:53 < timotimo> now i get it!
23​:57 < timotimo> i hadn't read what you wrote "back then"
23​:59 < timotimo> feel free to write that into the bug report and close it

To summarize, decontainerizing of the RHS is needed if it's an array element, which seems to make sense.

@p6rt
Copy link
Author

p6rt commented Apr 25, 2015

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

@p6rt
Copy link
Author

p6rt commented Apr 25, 2015

From @timo

as psch said. not a bug, WONTFIX etc etc

@p6rt
Copy link
Author

p6rt commented Apr 25, 2015

@timo - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Apr 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant