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

Something is inconsistent with the undef warnings of .reduce #524

Closed
p6rt opened this issue Dec 22, 2008 · 9 comments
Closed

Something is inconsistent with the undef warnings of .reduce #524

p6rt opened this issue Dec 22, 2008 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 22, 2008

Migrated from rt.perl.org#61610 (status was 'rejected')

Searchable as RT61610$

@p6rt
Copy link
Author

p6rt commented Dec 22, 2008

From @masak

<moritz_> rakudo​: say (1..10).reduce({$^a + $^b + $^c})
<p6eval> rakudo 34244​: OUTPUT[Use of uninitialized value␤55␤]
<PerlJam> that's interesting
* PerlJam is looking at the code now
<masak> PerlJam​: are you also submitting a rakudobug? otherwise I am.
<PerlJam> go ahead
* masak submits rakudobug
<eric256> whats the bug?
<masak> eric256​: the "Use of uninitialized value" warning above.
<moritz_> masak​: maybe that's because it just doesn't work to reduce a
list of every possible size with a three-arg function?
<eric256> but it was unitiliazed
<masak> moritz_​: yes, now that I look at it, I think so too.
<masak> eric256​: what was?
<PerlJam> still a bug though
<PerlJam> (IMHO)
<eric256> $^b and $^c for the last run
<masak> PerlJam​: aye, it shouldn't warn, methinks
<masak> eric256​: you're right.
<PerlJam> yeah, it pushes an appropriate number of undef to fill out
the arity of the sub.
<eric256> rakudo​: list(1).reduce( { $^a.say; $^b.say;});
<p6eval> rakudo 34244​: RESULT[1]
<rjh-> how else would you handle it?
<eric256> ohh but that should have the same error then
<eric256> rakudo​: list(1).reduce( { $^a + $^b;});
<p6eval> rakudo 34244​: RESULT[1]
<eric256> rakudo​: list(1).reduce( { $^a + $^b + $^c;});
<p6eval> rakudo 34244​: RESULT[1]
<eric256> rakudo​: list(1,2).reduce( { $^a + $^b + $^c;});
<p6eval> rakudo 34244​: OUTPUT[Use of uninitialized value␤]
<eric256> okay thats a bit weird
<masak> something inconsistent is going on.

@p6rt
Copy link
Author

p6rt commented Dec 22, 2008

From @markjreed

Arity 2 and a 1-elem list seems to be special-cased; otherwise, it
consistently warns once per undefined value in the expansion​:

(1..4).reduce({$^a+$^b+$^c+$^d}) # no warnings
(1..5).reduce({$^a+$^b+$^c+$^d}) # two warnings​: (1+2+3+4)+5+undef+undef
(1..6).reduce({$^a+$^b+$^c+$^d}) # one warning​: (1+2+3+4)+5+6+undef
(1..7).reduce({$^a+$^b+$^c+$^d}) # no warnings​: (1+2+3+4)+5+6+7
(1..8).reduce({$^a+$^b+$^c+$^d}) # two warnings​:
((1+2+3+4)+5+6+7)+8+undef+undef

On Mon, Dec 22, 2008 at 10​:11 AM, via RT Carl Mäsak
<perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by "Carl Mäsak"
# Please include the string​: [perl #​61610]
# in the subject line of all future correspondence about this issue.
# <URL​: http://rt.perl.org/rt3/Ticket/Display.html?id=61610 >

<moritz_> rakudo​: say (1..10).reduce({$^a + $^b + $^c})
<p6eval> rakudo 34244​: OUTPUT[Use of uninitialized value␤55␤]
<PerlJam> that's interesting
* PerlJam is looking at the code now
<masak> PerlJam​: are you also submitting a rakudobug? otherwise I am.
<PerlJam> go ahead
* masak submits rakudobug
<eric256> whats the bug?
<masak> eric256​: the "Use of uninitialized value" warning above.
<moritz_> masak​: maybe that's because it just doesn't work to reduce a
list of every possible size with a three-arg function?
<eric256> but it was unitiliazed
<masak> moritz_​: yes, now that I look at it, I think so too.
<masak> eric256​: what was?
<PerlJam> still a bug though
<PerlJam> (IMHO)
<eric256> $^b and $^c for the last run
<masak> PerlJam​: aye, it shouldn't warn, methinks
<masak> eric256​: you're right.
<PerlJam> yeah, it pushes an appropriate number of undef to fill out
the arity of the sub.
<eric256> rakudo​: list(1).reduce( { $^a.say; $^b.say;});
<p6eval> rakudo 34244​: RESULT[1]
<rjh-> how else would you handle it?
<eric256> ohh but that should have the same error then
<eric256> rakudo​: list(1).reduce( { $^a + $^b;});
<p6eval> rakudo 34244​: RESULT[1]
<eric256> rakudo​: list(1).reduce( { $^a + $^b + $^c;});
<p6eval> rakudo 34244​: RESULT[1]
<eric256> rakudo​: list(1,2).reduce( { $^a + $^b + $^c;});
<p6eval> rakudo 34244​: OUTPUT[Use of uninitialized value␤]
<eric256> okay thats a bit weird
<masak> something inconsistent is going on.

--
Mark J. Reed <markjreed@​gmail.com>

@p6rt
Copy link
Author

p6rt commented Dec 22, 2008

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

@p6rt
Copy link
Author

p6rt commented Dec 22, 2008

From @markjreed

Ok, so with that patch, the case of a 1-element list and a binary sub
now behaves the same as any other combination of arity n with a list
whose length is not k(n-1)+1. I guess that's progress. :) Thanks,
Vasily.

I'd still like to see the undef warnings reduced to one, rather than
one for every undef in the expansion.

On Mon, Dec 22, 2008 at 4​:17 PM, Vasily Chekalkin <bacek@​bacek.com> wrote​:

Mark J. Reed wrote​:

Arity 2 and a 1-elem list seems to be special-cased; otherwise, it
consistently warns once per undefined value in the expansion​:

1-elem List reduce patch attached. Test added in r24567

--
Bacek

--
Mark J. Reed <markjreed@​gmail.com>

@p6rt
Copy link
Author

p6rt commented Dec 22, 2008

From @bacek

Mark J. Reed wrote​:

Arity 2 and a 1-elem list seems to be special-cased; otherwise, it
consistently warns once per undefined value in the expansion​:

1-elem List reduce patch attached. Test added in r24567

--
Bacek

@p6rt
Copy link
Author

p6rt commented Dec 22, 2008

From @bacek

list_reduce.patch
commit 9c1a3058064067dacab4c5f623a59ae768f19182
Author: Vasily Chekalkin <bacek@bacek.com>
Date:   Tue Dec 23 08:12:19 2008 +1100

    Fix one element List reduce

diff --git a/languages/perl6/src/builtins/any-list.pir b/languages/perl6/src/builtins/any-list.pir
index eaa43c8..8761297 100644
--- a/languages/perl6/src/builtins/any-list.pir
+++ b/languages/perl6/src/builtins/any-list.pir
@@ -410,7 +410,6 @@ the size of that file down and to emphasize their generic,
     unless iter goto empty
     retv = shift iter
   loop:
-    unless iter goto done
 
     # Create arguments for closure
     args = new 'ResizablePMCArray'
@@ -432,6 +431,7 @@ the size of that file down and to emphasize their generic,
 
   invoke:
     retv = expression(retv, args :flat)
+    unless iter goto done
     goto loop
 
   empty:

@p6rt
Copy link
Author

p6rt commented Sep 19, 2010

From sohtil@gmail.com

Current rakudo refuses to reduce with non-binary functions​:

$ ./perl6

say (1..10).reduce({$^a + $^b + $^c})
===SORRY!===
Can only reduce() using a binary function for now.

This is Rakudo Perl 6, version 2010.08-119-gccde8dc built on parrot
2.7.0 r49158

Lithos

@p6rt
Copy link
Author

p6rt commented Jun 25, 2012

From @pmichaud

Since 'reduce' is now defined only on arity-2 functions, marking this
ticket as rejected.

Pm

@p6rt
Copy link
Author

p6rt commented Jun 25, 2012

@pmichaud - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Jun 25, 2012
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant