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

reduce metaop gets confused by IterationEnd sentinel #4581

Closed
p6rt opened this issue Sep 23, 2015 · 5 comments
Closed

reduce metaop gets confused by IterationEnd sentinel #4581

p6rt opened this issue Sep 23, 2015 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 23, 2015

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

Searchable as RT126146$

@p6rt
Copy link
Author

p6rt commented Sep 23, 2015

From zefram@fysh.org

The reduce metaoperator iterates through its list of operands in a
way that will be prematurely terminated if the IterationEnd sentinel
appears in the list. This is trivially demonstrated by reducing over
list construction, which ought to amount to list copying​:

$ ./perl6 -e 'say ([,] 2, 3, 4, 5, 6).perl'
(2, 3, 4, 5, 6)
$ ./perl6 -e 'say ([,] 2, 3, IterationEnd, 5, 6).perl'
(2, 3)

Obviously, being a public object that's part of the Iterator API, this can
in general appear in a user's list. The sentinel wouldn't normally be
used as an operand for the kind of operations one would stereotypically
reduce over, but it does have well-defined behaviour for such operators,
which is lost by the premature list termination​:

$ ./perl6 -e 'say 2 * IterationEnd'
X​::Multi​::NoMatch exception produced no message
  in block <unit> at -e​:1
$ ./perl6 -e 'say ([*] 2, IterationEnd, 3)'
2

-zefram

@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

From @jnthn

On Wed Sep 23 13​:19​:16 2015, zefram@​fysh.org wrote​:

The reduce metaoperator iterates through its list of operands in a
way that will be prematurely terminated if the IterationEnd sentinel
appears in the list. This is trivially demonstrated by reducing over
list construction, which ought to amount to list copying​:

$ ./perl6 -e 'say ([,] 2, 3, 4, 5, 6).perl'
(2, 3, 4, 5, 6)
$ ./perl6 -e 'say ([,] 2, 3, IterationEnd, 5, 6).perl'
(2, 3)

Obviously, being a public object that's part of the Iterator API, this can
in general appear in a user's list. The sentinel wouldn't normally be
used as an operand for the kind of operations one would stereotypically
reduce over, but it does have well-defined behaviour for such operators,
which is lost by the premature list termination​:

$ ./perl6 -e 'say 2 * IterationEnd'
X​::Multi​::NoMatch exception produced no message
in block <unit> at -e​:1
$ ./perl6 -e 'say ([*] 2, IterationEnd, 3)'
2

This is rejected for same reason as RT #​126147. Anyone using it for anything other than its intended purpose deserves what they get.

@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

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

@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

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

@p6rt p6rt closed this as completed Sep 24, 2015
@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

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

@p6rt p6rt added the Bug 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