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

min(+'a', +'a').say prints Inf but should produce an error #4294

Closed
p6rt opened this issue Jun 5, 2015 · 14 comments
Closed

min(+'a', +'a').say prints Inf but should produce an error #4294

p6rt opened this issue Jun 5, 2015 · 14 comments

Comments

@p6rt
Copy link

p6rt commented Jun 5, 2015

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

Searchable as RT125334$

@p6rt
Copy link
Author

p6rt commented Jun 5, 2015

From @AlexDaniel

Code​:
min(+'a', +'a').say

Result​:
Inf

Normally such conversion throws an error​:
Code​:
say +'a'

Result​:
Cannot convert string to number​: base-10 number must begin with valid
digits or '.' in '⏏a' (indicated by ⏏)
  in block <unit> at ./test.pl​:2

But that's not the case in min(). I'd probably accept any other result
(Error, 0, NaN, whatever), but not Inf.

@p6rt
Copy link
Author

p6rt commented Jun 8, 2015

From @coke

I agree that this should be throwing the same conversion error. Here's probably why it's giving Inf, though​:

$ perl6

say min()
Inf
say max()
-Inf

--
Will "Coke" Coleda

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jun 8, 2015

From @coke

I agree that this should be throwing the same conversion error. Here's probably why it's giving Inf, though​:

$ perl6

say min()
Inf
say max()
-Inf

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jun 8, 2015

From @pmichaud

On Mon, Jun 08, 2015 at 06​:08​:33AM -0700, Will Coleda via RT wrote​:

I agree that this should be throwing the same conversion error.

I disagree to the extent that making min() throw the conversion error seems
to go against the purpose of designing soft/lazy Failure types into Perl 6
in the first place.

Sometimes we speak about not having the entire rocket explode simply
because of a few errors in the input set. In this case, min() is designed
to silently ignore undefined values in its calculations. Since in this
example all of the input values were undefined, min returned its 0-arg
case of Inf.

Perhaps an argument could be made that if min() is invoked on a list
consisting only of undefined values, it should return the first (undefined)
value instead of Inf. In other words, undefined values end up in this
middle-region between "lowest defined value" and "Inf", or something like
that.

At any rate, at this moment it's more of a specification issue than an
actual rakudobug.

Pm

@p6rt
Copy link
Author

p6rt commented Jul 7, 2016

From @coke

On Mon Jun 08 12​:02​:55 2015, pmichaud wrote​:

On Mon, Jun 08, 2015 at 06​:08​:33AM -0700, Will Coleda via RT wrote​:

I agree that this should be throwing the same conversion error.

I disagree to the extent that making min() throw the conversion error seems
to go against the purpose of designing soft/lazy Failure types into Perl 6
in the first place.

Sometimes we speak about not having the entire rocket explode simply
because of a few errors in the input set. In this case, min() is designed
to silently ignore undefined values in its calculations. Since in this
example all of the input values were undefined, min returned its 0-arg
case of Inf.

Perhaps an argument could be made that if min() is invoked on a list
consisting only of undefined values, it should return the first (undefined)
value instead of Inf. In other words, undefined values end up in this
middle-region between "lowest defined value" and "Inf", or something like
that.

At any rate, at this moment it's more of a specification issue than an
actual rakudobug.

Pm

Even if this was a Failure under the covers, in his example, he's say-ing the value, which should trigger the error at the point.
--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jul 7, 2016

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

@p6rt
Copy link
Author

p6rt commented Jul 7, 2016

From @AlexDaniel

By the way, this was fixed. I'm not sure when, seems to be before 2015.10.

<AlexDaniel> m​: min(+'a', +'a').say
<camelia> rakudo-moar d1ebac​: OUTPUT«Cannot convert string to number​: base-10 number must begin with valid digits or '.' in '⏏a' (indicated by ⏏)␤ in block <unit> at <tmp> line 1␤␤Actually thrown at​:␤ in block <unit> at <tmp> line 1␤␤»

So it only needs tests.

@p6rt
Copy link
Author

p6rt commented Jul 8, 2016

From @zoffixznet

Tests added​: Raku/roast@683aeeaba8

@p6rt
Copy link
Author

p6rt commented Jul 8, 2016

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

@p6rt
Copy link
Author

p6rt commented Jul 8, 2016

From @salortiz

Seems to be agreement that the following two should be True, no?

  min(+'a') ~~ Failure
  min(+'a',+'a') ~~ Failure

@p6rt
Copy link
Author

p6rt commented Jul 8, 2016

From @AlexDaniel

Reopened per discussion on rakudo/rakudo#815 (comment)

@p6rt
Copy link
Author

p6rt commented Jul 8, 2016

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

@p6rt
Copy link
Author

p6rt commented Jul 12, 2016

From @zoffixznet

The decision has been reached and the referenced PR merged.

Tests unfudged in Raku/roast@78ccae4548

Re-closing.

--
Cheers,
ZZ | https://twitter.com/zoffix

@p6rt
Copy link
Author

p6rt commented Jul 12, 2016

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

@p6rt p6rt closed this as completed Jul 12, 2016
@p6rt p6rt added the testneeded label Jan 5, 2020
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