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 does the wrong thing with a one-param closure that calls a non-Num method #2552

Closed
p6rt opened this issue Nov 8, 2011 · 5 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Nov 8, 2011

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

Searchable as RT103178$

@p6rt
Copy link
Author

p6rt commented Nov 8, 2011

From @masak

<masak> rakudo​: Inf.S
<p6eval> rakudo c0b2e3​: OUTPUT«Method 'S' not found for invocant of
class 'Num' [...]
<masak> rakudo​: class A { has Int $.S = 0 }; say (A.new, A.new, A.new).min(*.S)
<p6eval> rakudo c0b2e3​: OUTPUT«Method 'S' not found for invocant of
class 'Num' [...]
<masak> I think the former is what's happening in the latter.
* masak submits rakudobug
<masak> Inf is nice and all, but I think the above shows that the
value Inf is not enough in the .min method (because we don't want to
call Inf.S) -- rather, we need to special-case the initial value of
the accumulator variable somehow.
<masak> TimToady​: this would be a case of using an in-band value and
wishing it were out-of-band, I guess :)
<masak> put differently, you can't both have Inf in that algorithm,
and arbitrary closures that invoke on the smallest-value-found-so-far.

@p6rt
Copy link
Author

p6rt commented Jan 6, 2012

From @jnthn

On Tue Nov 08 08​:46​:33 2011, masak wrote​:

<masak> rakudo​: Inf.S
<p6eval> rakudo c0b2e3​: OUTPUT�Method 'S' not found for invocant of
class 'Num' [...]
<masak> rakudo​: class A { has Int $.S = 0 }; say (A.new, A.new,
A.new).min(*.S)
<p6eval> rakudo c0b2e3​: OUTPUT�Method 'S' not found for invocant of
class 'Num' [...]
<masak> I think the former is what's happening in the latter.
* masak submits rakudobug
<masak> Inf is nice and all, but I think the above shows that the
value Inf is not enough in the .min method (because we don't want to
call Inf.S) -- rather, we need to special-case the initial value of
the accumulator variable somehow.
<masak> TimToady​: this would be a case of using an in-band value and
wishing it were out-of-band, I guess :)
<masak> put differently, you can't both have Inf in that algorithm,
and arbitrary closures that invoke on the smallest-value-found-so-far.

Now​:

18​:49 < moritz> rakudo​: class A { has Int $.S = 0 }; say (A.new, A.new,
  A.new).min(*.S)
18​:49 <+p6eval> rakudo bbdc78​: OUTPUT«A.new(S => 0)␤»

Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jan 6, 2012

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

@p6rt
Copy link
Author

p6rt commented Jan 6, 2012

From @moritz

now tested in t/spec/S32-list/minmax.t

@p6rt
Copy link
Author

p6rt commented Jan 6, 2012

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