Closed p6rt closed 15 years ago
src/builtins/any-list.pir | 47 --------------------------------------------- src/setting/Any-list.pm | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 48 deletions(-)
On Sat Mar 07 21:50:00 2009, bacek wrote:
--- src/builtins/any-list.pir | 47 --------------------------------------------- src/setting/Any-list.pm | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 48 deletions(-)
Applied as a7214ac28c5c7c47932f1e76a15c8707524f964d, thanks.
Moritz
The RT System itself - Status changed from 'new' to 'open'
@moritz - Status changed from 'open' to 'resolved'
@pmichaud - Status changed from 'resolved' to 'open'
On Sat, Mar 07, 2009 at 09:50:02PM -0800, Vasily Chekalkin wrote:
+our List multi min(*@values) { + my $by = @values[0] ~~ Code ?? shift @values !! sub { $^a cmp $^b }; + @values.min($by); +}
This doesn't match the spec -- the $by parameter is required. At any rate, the first argument should not be explicitly checked for being a Code object -- if we do this it should be via a multi signature.
Yes, the PIR code was "cheating" in this respect, but I don't want to blindly copy our cheats from PIR into the setting without subjecting them to another review.
+ # RT #63700 - parse failed on &infix:\
+ our Array multi method min( $values: Code $by = sub { $^a cmp $^b } ) { + my @list = $values.list; + return +Inf unless @list.elems; + my $res = @list.shift; + for @list -> $x { + if (&$by($res, $x) > 0) { + $res = $x; + } + } + $res; + }; }
Why are C\?
Shouldn't they just return the single element that is the minimum
or maximum from the list?
Pm
Patrick R. Michaud wrote:
On Sat, Mar 07, 2009 at 09:50:02PM -0800, Vasily Chekalkin wrote:
+our List multi min(*@values) { + my $by = @values[0] ~~ Code ?? shift @values !! sub { $^a cmp $^b }; + @values.min($by); +}
This doesn't match the spec -- the $by parameter is required. At any rate, the first argument should not be explicitly checked for being a Code object -- if we do this it should be via a multi signature.
I've fixed that, and corrected the spec tests accordingly.
Yes, the PIR code was "cheating" in this respect, but I don't want to blindly copy our cheats from PIR into the setting without subjecting them to another review.
+ # RT #63700 - parse failed on &infix:\
+ our Array multi method min( $values: Code $by = sub { $^a cmp $^b } ) { + my @list = $values.list; + return +Inf unless @list.elems; + my $res = @list.shift; + for @list -> $x { + if (&$by($res, $x) > 0) { + $res = $x; + } + } + $res; + }; } Why are C\
and C\ specced as returning C\ and C\ ? Shouldn't they just return the single element that is the minimum or maximum from the list?
I agree, so I removed the non-sense return types from the specs.
Cheers, Moritz
Patrick R. Michaud via RT wrote:
On Sat, Mar 07, 2009 at 09:50:02PM -0800, Vasily Chekalkin wrote:
+our List multi min(*@values) { + my $by = @values[0] ~~ Code ?? shift @values !! sub { $^a cmp $^b }; + @values.min($by); +}
This doesn't match the spec -- the $by parameter is required. At any rate, the first argument should not be explicitly checked for being a Code object -- if we do this it should be via a multi signature.
Yes, the PIR code was "cheating" in this respect, but I don't want to blindly copy our cheats from PIR into the setting without subjecting them to another review.
This is workaround for this situation:
\
Should I fill bug report for this?
-- Bacek
On Mon Mar 09 00:41:24 2009, bacek wrote:
Patrick R. Michaud via RT wrote:
At any rate, the first argument should not be explicitly checked for being a Code object -- if we do this it should be via a multi signature.
Yes, the PIR code was "cheating" in this respect, but I don't want to blindly copy our cheats from PIR into the setting without subjecting them to another review.
This is workaround for this situation:
\
rakudo: multi sub foo(Code &x, *@values) {...}; multi sub foo(*@values) {...}; say foo(sub {}, 1,2,3); \ rakudo 2daf6b: OUTPUT«Ambiguous dispatch to multi 'foo'. Ambiguous candidates had signatures::(Code x, Any @values):(Any @values)current instr.: '_block14' pc 101 (EVAL_18:52)» Should I fill bug report for this?
Yes please. Closing this ticket, thanks!
Pm
@pmichaud - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#63712 (status was 'resolved')
Searchable as RT63712$