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

spliced argument requires eager evaluation #3547

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

spliced argument requires eager evaluation #3547

p6rt opened this issue Oct 11, 2014 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Oct 11, 2014

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

Searchable as RT122948$

@p6rt
Copy link
Author

p6rt commented Oct 11, 2014

From @pmichaud

The .infinite method on Any is designed to return one of three values​:
  True - known to be infinite
  False - known to be finite
  Nil - finite-ness not yet known or determined

The "Nil" (undefined) result is often provided for lists that are being evaluated lazily... rather than force eager evaluation of the list, the list can simply return an undefined value meaning "I don't know yet if I'm finite or infinite".

With that in mind, something about splicing Captures isn't properly honoring .infinite. Here's an illustration​:

  03​:08 <pmichaud> r​: sub g(*@​v) { say @​v.infinite; }; g(4..*); # correct
  03​:08 <camelia> rakudo-{parrot,moar} fd017a​: OUTPUT«True␤»
  03​:08 <pmichaud> r​: sub g(*@​v) { say @​v.infinite; }; g('a',4..*); # correct
  03​:08 <camelia> rakudo-{parrot,moar} fd017a​: OUTPUT«Nil␤»
  03​:08 <pmichaud> r​: sub g(*@​v) { say @​v.infinite; }; g(|('a',4..*)); # correct
  03​:08 <camelia> rakudo-{parrot,moar} fd017a​: OUTPUT«Nil␤»
  03​:08 <pmichaud> r​: sub g(*@​v) { say @​v.infinite; }; g(|(4..*)); # incorrect
  03​:08 <camelia> rakudo-{parrot,moar} fd017a​: OUTPUT«False␤»

The last case shows the problem -- when a Capture has a single infinite argument, splicing it into the slurpy paramete loses its finite nature. Either "True" or "Nil" would be acceptable for this last answer, but "False" is the absolute wrong result.

This is ultimately the cause of the bug described in RT #​118867 dealing with the [max] reduction operator.

Pm

@p6rt
Copy link
Author

p6rt commented Oct 11, 2014

From @pmichaud

After discussion with jnthn tonight after APW '14.

Ignore everything above -- the bug is in fact somewhat different.

The short answer is that spliced arguments need to be eagerly evaluated. Currently they're only partially evaluated using .gimme(*), which may be insufficient for argument passing or dispatch.

The result of a call like g(|(1..*)) should be either an infinite hang (generating an infinite list) or an exception generated as a result of attempting to eagerly evaluate an infinite Iterable.

(Currently Rakudo neither hangs nor throws an exception on (1..*).eager, which is a separate bug.)

Pm

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

From @niner

The result of a call like g(|(1..*)) should be either an infinite
hang (generating an infinite list) or an exception generated as a
result of attempting to eagerly evaluate an infinite Iterable.

g(|(1..*)) does indeed hang, now that the GLR is merged.

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

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

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

From @niner

closed

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

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

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

No branches or pull requests

1 participant