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

Num doesn't have a Range coercer #3737

Closed
p6rt opened this issue Mar 16, 2015 · 8 comments
Closed

Num doesn't have a Range coercer #3737

p6rt opened this issue Mar 16, 2015 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Mar 16, 2015

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

Searchable as RT124082$

@p6rt
Copy link
Author

p6rt commented Mar 16, 2015

From @Tux

$ p6 -e'int.Range.say'
-9223372036854775808..9223372036854775807
$ p6 -e'int.Range.max.say'
9223372036854775807
$ p6 -e'Int.Range.say'
-Inf..Inf
$ p6 -e'Int.Range.max.say'
Inf
$ p6 -e'Num.Range.say'
No such method 'Range' for invocant of type 'Num'
  in block <unit> at -e​:1

$ p6 -e'my int $i = int.Range.max; $i.say'
9223372036854775807
$ p6 -e'my Int $i = Int.Range.max; $i.say'
Type check failed in assignment to '$i'; expected 'Int' but got 'Num'
  in block <unit> at -e​:1

$ p6 -e'Inf.WHAT.say'
(Num)
$ p6 -e'Inf.Int.WHAT.say'
(Failure)

--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.21 porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/

@p6rt
Copy link
Author

p6rt commented Mar 19, 2015

From @masak

I see two things in this ticket. Correct me if I'm wrong.

$ p6 -e'Num.Range.say'
No such method 'Range' for invocant of type 'Num'
in block <unit> at -e​:1

First thing​: Num doesn't have a Range coercer.

$ p6 -e'my Int $i = Int.Range.max; $i.say'
Type check failed in assignment to '$i'; expected 'Int' but got 'Num'
in block <unit> at -e​:1

Second thing​: can't put Inf in Int, which is a dupe of https://rt.perl.org/Ticket/Display.html?id=61602, which is currently blocking on Raku/old-design-docs#27 but the last word on which is http://irclog.perlgeek.de/perl6/2014-08-20#i_9217322, IMO.

So, mind if I change the name of this ticket to "Num doesn't have a Range coercer"? :)

@p6rt
Copy link
Author

p6rt commented Mar 19, 2015

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

@p6rt
Copy link
Author

p6rt commented Mar 20, 2015

From @Tux

On Thu, 19 Mar 2015 12​:02​:36 -0700, "Carl Mäsak via RT"
<perl6-bugs-followup@​perl.org> wrote​:

I see two things in this ticket. Correct me if I'm wrong.

$ p6 -e'Num.Range.say'
No such method 'Range' for invocant of type 'Num'
in block <unit> at -e​:1

First thing​: Num doesn't have a Range coercer.

$ p6 -e'my Int $i = Int.Range.max; $i.say'
Type check failed in assignment to '$i'; expected 'Int' but got 'Num'
in block <unit> at -e​:1

Second thing​: can't put Inf in Int,

In which case Int.Range.max should not return Inf IMHO. Maybe it should
return int8.Range.max instead. If you cannot put Int.Range.max in Int,
that is extremely counter-inutitive

which is a dupe of https://rt-archive.perl.org/perl6/Ticket/Display.html?id=61602,
which is currently blocking on Raku/old-design-docs#27
but the last word on which is
http://irclog.perlgeek.de/perl6/2014-08-20#i_9217322, IMO.

That, at the moment, is beyond my current level of understanding the
core :)

So, mind if I change the name of this ticket to "Num doesn't have
a Range coercer"? :)

Is ok.

--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.21 porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/

@p6rt
Copy link
Author

p6rt commented Mar 21, 2015

From @masak

Tux (>>>), masak (>>), Tux (>)​:

$ p6 -e'my Int $i = Int.Range.max; $i.say'
Type check failed in assignment to '$i'; expected 'Int' but got 'Num'
in block <unit> at -e​:1

Second thing​: can't put Inf in Int,

In which case Int.Range.max should not return Inf IMHO. Maybe it should
return int8.Range.max instead. If you cannot put Int.Range.max in Int,
that is extremely counter-inutitive

Oh, no, you got me diametrically wrong. I identified two separate bug reports in your ticket, the second of which is that the Inf value cannot be put in an Int container. It *should* totally be possible, at least by current synopsis/TimToady/community consensus. But it isn't yet. What I identified as your "Second thing" was simply this discrepancy.

So, mind if I change the name of this ticket to "Num doesn't have
a Range coercer"? :)

Is ok.

Renaming.

@p6rt
Copy link
Author

p6rt commented Aug 29, 2015

From @coke

On Mon Mar 16 05​:01​:38 2015, hmbrand wrote​:

$ p6 -e'int.Range.say'
-9223372036854775808..9223372036854775807
$ p6 -e'int.Range.max.say'
9223372036854775807
$ p6 -e'Int.Range.say'
-Inf..Inf
$ p6 -e'Int.Range.max.say'
Inf
$ p6 -e'Num.Range.say'
No such method 'Range' for invocant of type 'Num'
in block <unit> at -e​:1

$ p6 -e'my int $i = int.Range.max; $i.say'
9223372036854775807
$ p6 -e'my Int $i = Int.Range.max; $i.say'
Type check failed in assignment to '$i'; expected 'Int' but got 'Num'
in block <unit> at -e​:1

$ p6 -e'Inf.WHAT.say'
(Num)
$ p6 -e'Inf.Int.WHAT.say'
(Failure)

15​:37 < [Coke]> m​: Int.Range.say; Num.Range.say;
15​:37 <+camelia> rakudo-moar 6a1879​: OUTPUT«-Inf..Inf␤-Inf..Inf␤»
15​:37 < GLRelia> rakudo-moar a057dd​: OUTPUT«(timeout)»
15​:38 < [Coke]> ^^ There's another GLR bug.

So, this exists now... but it's broken in GLR.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Sep 13, 2015

From @niner

This seems to have been fixed in the meantime. Num.Range.say prints -Inf..Inf

@p6rt p6rt closed this as completed Sep 13, 2015
@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