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

'for' loop in sink context isn't invoking block in sink context #3567

Closed
p6rt opened this issue Oct 28, 2014 · 6 comments
Closed

'for' loop in sink context isn't invoking block in sink context #3567

p6rt opened this issue Oct 28, 2014 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 28, 2014

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

Searchable as RT123072$

@p6rt
Copy link
Author

p6rt commented Oct 28, 2014

From @pmichaud

This is a reminder/placeholder ticket for a bug I found tonight while
researching GLR-related topics. A "for" loop executed in sink context
isn't executing its block in sink context. From #perl6​:

  04​:50 <pmichaud> m​: class Sinker { method sink() { say "Blub" } }; my $i = 0; while $i < 5 { $i++; Sinker.new(); }; 1
  04​:50 <camelia> rakudo-moar 315ec6​: OUTPUT«Blub␤Blub␤Blub␤Blub␤Blub␤»
  04​:50 <pmichaud> m​: class Sinker { method sink() { say "Blub" } }; for ^5 { Sinker.new(); }; 1
  04​:50 <camelia> rakudo-moar 315ec6​: ( no output )

Earlier in the conversation​:

  00​:38 <pmichaud> ...which one is "correct"? (post-GLR)
  00​:41 <pmichaud> i.e., does a loop executed in sink context execute its body in sink context?
  03​:16 <TimToady> pmichaud​: why would a loop in sink context ever want a value from its loop body?
  03​:16 <TimToady> I'm a bit surprised the 2nd one isn't sunk already
  03​:21 <TimToady> well, not really, given what I know about internals :)
  04​:39 <pmichaud> TimToady​: I'm not surprised the second one isn't sunk already; sink context in Rakudo is (still) somewhat inconsistently handled.
  04​:40 <pmichaud> Implementors sometimes remembered to throw away the values, but forgot to tell the values they were being thrown away.
  04​:41 <pmichaud> anyway, I'll be looking at fixing that shortly

The bug will likely be taken care of as part of the GLR; this ticket is to remind us that we need a test for it. :)

Pm

@p6rt
Copy link
Author

p6rt commented Aug 29, 2015

From @coke

On Mon Oct 27 21​:55​:46 2014, pmichaud wrote​:

This is a reminder/placeholder ticket for a bug I found tonight while
researching GLR-related topics. A "for" loop executed in sink context
isn't executing its block in sink context. From #perl6​:

04​:50 <pmichaud> m​: class Sinker { method sink() { say "Blub" } };
my $i = 0; while $i < 5 { $i++; Sinker.new(); }; 1
04​:50 <camelia> rakudo-moar 315ec6​: OUTPUT«Blub␤Blub␤Blub␤Blub␤Blub␤»
04​:50 <pmichaud> m​: class Sinker { method sink() { say "Blub" } };
for ^5 { Sinker.new(); }; 1
04​:50 <camelia> rakudo-moar 315ec6​: ( no output )

Earlier in the conversation​:

00​:38 <pmichaud> ...which one is "correct"? (post-GLR)
00​:41 <pmichaud> i.e., does a loop executed in sink context execute
its body in sink context?
03​:16 <TimToady> pmichaud​: why would a loop in sink context ever want
a value from its loop body?
03​:16 <TimToady> I'm a bit surprised the 2nd one isn't sunk already
03​:21 <TimToady> well, not really, given what I know about internals
:)
04​:39 <pmichaud> TimToady​: I'm not surprised the second one isn't sunk
already; sink context in Rakudo is (still) somewhat inconsistently
handled.
04​:40 <pmichaud> Implementors sometimes remembered to throw away the
values, but forgot to tell the values they were being thrown away.
04​:41 <pmichaud> anyway, I'll be looking at fixing that shortly

The bug will likely be taken care of as part of the GLR; this ticket
is to remind us that we need a test for it. :)

Pm

behavior updated, consistent currently in nom and glr.

15​:11 < [Coke]> m​: class Sinker { method sink() { say "Blub" } }; my $i = 0;
  while $i < 5 { $i++; Sinker.new(); }; 1
15​:11 <+camelia> rakudo-moar 6a1879​: OUTPUT«WARNINGS​:␤Useless use of constant
  integer 1 in sink context (line 1)␤Blub␤Blub␤Blub␤Blub␤Blub␤»
15​:11 < GLRelia> rakudo-moar a977dc​: OUTPUT«WARNINGS​:␤Useless use of constant
  integer 1 in sink context (line 1)␤Blub␤Blub␤Blub␤Blub␤Blub␤»
15​:11 < [Coke]> m​: class Sinker { method sink() { say "Blub" } }; for ^5 {
  Sinker.new(); }; 1
15​:11 <+camelia> rakudo-moar 6a1879​: OUTPUT«WARNINGS​:␤Useless use of constant
  integer 1 in sink context (line 1)␤»
15​:11 < GLRelia> rakudo-moar a977dc​: OUTPUT«WARNINGS​:␤Useless use of constant
  integer 1 in sink context (line 1)␤»

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 29, 2015

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

@p6rt
Copy link
Author

p6rt commented Aug 13, 2016

From @TimToady

Some method calls were not properly sunk as a final statement in a loop.

Fix in 977797fa401856e5310155f13469b7e6ff5f620a

Test in bc8fa4fd8d449573eb6001b5f43f8890f65b9196

1 similar comment
@p6rt
Copy link
Author

p6rt commented Aug 13, 2016

From @TimToady

Some method calls were not properly sunk as a final statement in a loop.

Fix in 977797fa401856e5310155f13469b7e6ff5f620a

Test in bc8fa4fd8d449573eb6001b5f43f8890f65b9196

@p6rt
Copy link
Author

p6rt commented Aug 13, 2016

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

@p6rt p6rt closed this as completed Aug 13, 2016
@p6rt p6rt added the glr label Jan 5, 2020
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