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

Sequence operator produces Rats which it should produce Ints #2223

Closed
p6rt opened this issue Oct 10, 2010 · 10 comments
Closed

Sequence operator produces Rats which it should produce Ints #2223

p6rt opened this issue Oct 10, 2010 · 10 comments

Comments

@p6rt
Copy link

p6rt commented Oct 10, 2010

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

Searchable as RT78324$

@p6rt
Copy link
Author

p6rt commented Oct 10, 2010

From @masak

<TimToady> rakudo​: ~(64,32,16 ...^ Rat)
<TimToady> that ought to work
<p6eval> rakudo 668719​: OUTPUT«(timeout)»
<TimToady> but it doesn't

@p6rt
Copy link
Author

p6rt commented Feb 20, 2011

From @moritz

On Sun Oct 10 16​:19​:38 2010, masak wrote​:

<TimToady> rakudo​: ~(64,32,16 ...^ Rat)
<TimToady> that ought to work
<p6eval> rakudo 668719​: OUTPUT«(timeout)»
<TimToady> but it doesn't

FWIW this now terminates, but quite early​:

17​:04 < moritz_> rakudo​: say ~(64,32,16 ...^ Rat)
17​:05 <+p6eval> rakudo 37eafa​: OUTPUT«64 32 16␤»
17​:05 < masak> eh?
17​:05 < moritz_> it doesn't re-coerce to int
17​:05 < moritz_> it calculates 8 as 1/2 * 16
17​:05 < moritz_> which is a Rat

Seems to be missing a coercion step.

But type objects now work as stoppers in general.

@p6rt
Copy link
Author

p6rt commented Feb 20, 2011

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

@p6rt
Copy link
Author

p6rt commented May 30, 2013

From @coke

On Sun Feb 20 08​:07​:38 2011, moritz wrote​:

On Sun Oct 10 16​:19​:38 2010, masak wrote​:

<TimToady> rakudo​: ~(64,32,16 ...^ Rat)
<TimToady> that ought to work
<p6eval> rakudo 668719​: OUTPUT«(timeout)»
<TimToady> but it doesn't

FWIW this now terminates, but quite early​:

17​:04 < moritz_> rakudo​: say ~(64,32,16 ...^ Rat)
17​:05 <+p6eval> rakudo 37eafa​: OUTPUT«64 32 16␤»
17​:05 < masak> eh?
17​:05 < moritz_> it doesn't re-coerce to int
17​:05 < moritz_> it calculates 8 as 1/2 * 16
17​:05 < moritz_> which is a Rat

Seems to be missing a coercion step.

But type objects now work as stoppers in general.

This raises a spec question over at Raku/old-design-docs#47

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented May 30, 2013

From @moritz

On Sun Oct 10 16​:19​:38 2010, masak wrote​:

<TimToady> rakudo​: ~(64,32,16 ...^ Rat)
<TimToady> that ought to work

FWIW I expected this to print 64 32 16 8 4 2 1

@p6rt
Copy link
Author

p6rt commented Nov 26, 2014

From @usev6

The issue Raku/old-design-docs#47 has been closed by the end of last year. Now there is a method "narrow" which can be used in this case (I'll add a test for this)​:

$ perl6 -e 'say ~( 64, {($_/2).narrow} ...^ Rat)'
64 32 16 8 4 2 1

The sequence operator doesn't auto-coerce Rats to Ints (same behaviour as back in 2010; there also is a passing test for this behaviour in S03-sequence/basic.t since 2010-10-21).

$ perl6 -e 'say ~(64,32,16 ...^ Rat)'
64 32 16

So, was a consensus reached and this ticket can be closed?

1 similar comment
@p6rt
Copy link
Author

p6rt commented Nov 26, 2014

From @usev6

The issue Raku/old-design-docs#47 has been closed by the end of last year. Now there is a method "narrow" which can be used in this case (I'll add a test for this)​:

$ perl6 -e 'say ~( 64, {($_/2).narrow} ...^ Rat)'
64 32 16 8 4 2 1

The sequence operator doesn't auto-coerce Rats to Ints (same behaviour as back in 2010; there also is a passing test for this behaviour in S03-sequence/basic.t since 2010-10-21).

$ perl6 -e 'say ~(64,32,16 ...^ Rat)'
64 32 16

So, was a consensus reached and this ticket can be closed?

@p6rt
Copy link
Author

p6rt commented Jan 31, 2015

From @usev6

<masak> bartolin​: you were the one who made a deal with #perl6, no? for every 5 RT tickets given a test, #perl6 owes you to un-stuck one RT ticket. do we owe you any at this point?
<bartolin> masak​: oh, actually atm I only have a short list of tickets for #perl6. but I'd had to ask RT how many questions I have
  one ticket from my list is RT #​78324
<moritz> bartolin​: TimToady++ specced the .narrow method in response to the github discussion
  bartolin​: but didn't clarify whether the sequence operator should call it
  so still undecided. I'd argue that the current behavior is correct, so I'd close it (with tests)
  m​: say (4/2).^name, (4/2).narrow.^name
<camelia> rakudo-moar 7fd2f6​: OUTPUT«RatInt␤»
<bartolin> moritz​: sounds good to me, thanks!
<masak> bartolin​: #​78324 looks to me like it could be closed, yes.

Since there are passing tests in S03-sequence/basic.t, I'm closing this ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jan 31, 2015

From @usev6

<masak> bartolin​: you were the one who made a deal with #perl6, no? for every 5 RT tickets given a test, #perl6 owes you to un-stuck one RT ticket. do we owe you any at this point?
<bartolin> masak​: oh, actually atm I only have a short list of tickets for #perl6. but I'd had to ask RT how many questions I have
  one ticket from my list is RT #​78324
<moritz> bartolin​: TimToady++ specced the .narrow method in response to the github discussion
  bartolin​: but didn't clarify whether the sequence operator should call it
  so still undecided. I'd argue that the current behavior is correct, so I'd close it (with tests)
  m​: say (4/2).^name, (4/2).narrow.^name
<camelia> rakudo-moar 7fd2f6​: OUTPUT«RatInt␤»
<bartolin> moritz​: sounds good to me, thanks!
<masak> bartolin​: #​78324 looks to me like it could be closed, yes.

Since there are passing tests in S03-sequence/basic.t, I'm closing this ticket now.

@p6rt
Copy link
Author

p6rt commented Jan 31, 2015

@usev6 - 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