One extra patch for this change: an error if the limit-function is a multi
(not sure if you'll want to apply this as-is: I couldn't figure out why
"fail" didn't result in an error. so used "die", instead).

On Thu, Feb 17, 2011 at 2:35 PM, perl6 via RT
<perl6-bugs-follo...@perl.org>wrote:

> Greetings,
>
> This message has been automatically generated in response to the
> creation of a trouble ticket regarding:
>        "[PATCH] Sequence operator supports limit function with arity > 1",
> a summary of which appears below.
>
> There is no need to reply to this message right now.  Your ticket has been
> assigned an ID of [perl #84362].
>
> Please include the string:
>
>         [perl #84362]
>
> in the subject line of all future correspondence about this issue. To do
> so,
> you may reply to this message.
>
>                        Thank you,
>                        perl6-bugs-follo...@perl.org
>
> -------------------------------------------------------------------------
> Attached patches add tests and implementation for sequence operator with
> limit-function arity > 1 (the function is assumed to be false until we have
> enough values to call it). The tests show how this can be used to terminate
> a sequence when it converges, or when a specific curvature is seen:
>
>  1, */2 ... abs(*-*) < 0.01;    ## convergence: 8 values
>  0,1,2,1,0,1,2 ...^ { $^a-$^b > $^b-$^c };  ## curvature: 5 values
>  1,2 ... { @_ == 4 };   ## length: 4 values
>
>
From 2312784b7a147bf2613b3e95f5ae37ed8dbbccaa Mon Sep 17 00:00:00 2001
From: Dave Whipp <dwh...@google.com>
Date: Fri, 25 Feb 2011 09:27:03 -0800
Subject: [PATCH] add error for use of Multi as sequence limit

---
 src/core/operators.pm |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/core/operators.pm b/src/core/operators.pm
index 074db9f..980a86e 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -401,7 +401,7 @@ our sub _HELPER_generate-series(@lhs, $rhs , :$exclude-limit) {
     my $limit = ($rhs ~~ Whatever ?? Any !! $rhs);
     return infinite-series(@lhs , $limit) if $rhs ~~ Whatever; #shortcut infinite series so we avoid the comparisions
 
-    #fail ('Limit arity cannot be larger than 1') if   $limit ~~ Code && $limit.count > 1;
+    die 'Sequence limit cannot be a multi-sub or multi-method' if $limit ~~ Multi;
     my $series = infinite-series(@lhs , $limit);
 
     gather {
-- 
1.7.3.1

Reply via email to