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 with user-defined sub fail #1042

Closed
p6rt opened this issue Jun 6, 2009 · 9 comments
Closed

reduce with user-defined sub fail #1042

p6rt opened this issue Jun 6, 2009 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Jun 6, 2009

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

Searchable as RT66352$

@p6rt
Copy link
Author

p6rt commented Jun 6, 2009

From daniel@ruoso.com

<ruoso> rakudo​: multi a (Str $a, Str $b) { [+$a, +$b] }; multi a (Array
$a, $b where '+') { [+] @​($a) }; ('1', '2', '+').reduce​: &a;
<p6eval> rakudo fb2fd4​: OUTPUT«Unknown introspection value
'pos_required'␤in method Any​::reduce (src/gen_setting.pm​:3226)␤called
from Main (/tmp/MvPkx61zJn​:2)␤»

daniel

@p6rt
Copy link
Author

p6rt commented Jun 14, 2009

From @pmichaud

On Sat, Jun 06, 2009 at 08​:01​:50AM -0700, Daniel Ruoso wrote​:

<ruoso> rakudo​: multi a (Str $a, Str $b) { [+$a, +$b] }; multi a (Array
$a, $b where '+') { [+] @​($a) }; ('1', '2', '+').reduce​: &a;
<p6eval> rakudo fb2fd4​: OUTPUT«Unknown introspection value
'pos_required'␤in method Any​::reduce (src/gen_setting.pm​:3226)␤called
from Main (/tmp/MvPkx61zJn​:2)␤»

At present C<reduce> doesn't work well with multisubs, as it's
not certain how to find the arity of the (multi)sub to pass
along to reduce.

It may be that we want reduce to simply assume arity 2.

Pm

@p6rt
Copy link
Author

p6rt commented Jun 14, 2009

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

@p6rt
Copy link
Author

p6rt commented Jun 14, 2009

From daniel@ruoso.com

Em Dom, 2009-06-14 às 10​:09 -0500, Patrick R. Michaud escreveu​:

On Sat, Jun 06, 2009 at 08​:01​:50AM -0700, Daniel Ruoso wrote​:

<ruoso> rakudo​: multi a (Str $a, Str $b) { [+$a, +$b] }; multi a (Array
$a, $b where '+') { [+] @​($a) }; ('1', '2', '+').reduce​: &a;
<p6eval> rakudo fb2fd4​: OUTPUT«Unknown introspection value
'pos_required'␤in method Any​::reduce (src/gen_setting.pm​:3226)␤called
from Main (/tmp/MvPkx61zJn​:2)␤»
At present C<reduce> doesn't work well with multisubs, as it's
not certain how to find the arity of the (multi)sub to pass
along to reduce.

This is a different problem indeed. We still don't know what to do in
reduce with varying arity multis, but this specific example shows a case
with fixed arity in all the candidates.

It may be that we want reduce to simply assume arity 2.

I'm not sure that is a sane option... Since we have the ... operator
(which I like to think as the inverse of reduce), that should be able to
work with multies as well...

daniel

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

From @bbkr

On Kiev build

$ perl6 -e 'multi a (Str $a, Str $b) { [+$a, +$b] }; multi a (Array $a,
$b where "+") { [+] @​($a) }; say ("1", "2", "+").reduce​: &a;'
3

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

From @coke

Today​:

$ ./perl6 -e 'multi a (Str $a, Str $b) { [+$a, +$b] }; multi a (Array
$a,$b where "+") { [+] @​($a) }; say ("1", "2", "+").reduce​: &a;'
can only reduce with arity 2 for now
  in method reduce at src/gen/CORE.setting​:4207
  in method reduce at src/gen/CORE.setting​:1029

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Fri Sep 30 17​:44​:43 2011, coke wrote​:

Today​:

$ ./perl6 -e 'multi a (Str $a, Str $b) { [+$a, +$b] }; multi a (Array
$a,$b where "+") { [+] @​($a) }; say ("1", "2", "+").reduce​: &a;'
can only reduce with arity 2 for now
in method reduce at src/gen/CORE.setting​:4207
in method reduce at src/gen/CORE.setting​:1029

new behavior​:

17​:27 <diakopter> r​: multi a (Str $a, Str $b) { [+$a, +$b] }; multi a
(Array $a,$b where
  "+") { [+] @​($a) }; say ("1", "2", "+").reduce​: &a;
17​:27 <p6eval> rakudo 024843​: OUTPUT«3␤»

@p6rt
Copy link
Author

p6rt commented Aug 7, 2012

From @moritz

The newest behavior is correct, and now tested in S32-list/reduce.t.

@p6rt
Copy link
Author

p6rt commented Aug 7, 2012

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

@p6rt p6rt closed this as completed Aug 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant