Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deprecate grep-index/first-index/last-index
  • Loading branch information
lizmat committed Oct 17, 2015
1 parent 697cfa6 commit c589177
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/core/Any-iterable-methods.pm
Expand Up @@ -1347,26 +1347,40 @@ augment class Any {
}
}

# DEPRECATE ???
proto method grep-index(|) is nodal { * }
multi method grep-index(Bool:D $t) {
fail X::Match::Bool.new( type => '.grep-index' );
}
multi method grep-index(Regex:D \t) { self!grep-k({$_.match(t)}) }
multi method grep-index(Callable:D \t) { self!grep-k(t) }
multi method grep-index(Mu \t) { self!grep-k({t.ACCEPTS($_)}) }
multi method grep-index(Regex:D \t) {
DEPRECATED('grep(:k)');
self!grep-k({$_.match(t)})
}
multi method grep-index(Callable:D \t) {
DEPRECATED('grep(:k)');
self!grep-k(t)
}
multi method grep-index(Mu \t) {
DEPRECATED('grep(:k)');
self!grep-k({t.ACCEPTS($_)})
}

proto method first-index(|) is nodal { * }
multi method first-index(Bool:D $ ) {
fail X::Match::Bool.new( type => '.first-index' );
}
multi method first-index(Mu \test) { self.first(test,:k) }
multi method first-index(Mu \test) {
DEPRECATED('first(:k)');
self.first(test,:k)
}

proto method last-index(|) is nodal { * }
multi method last-index(Bool:D $ ) {
fail X::Match::Bool.new( type => '.last-index' );
}
multi method last-index(Mu \test) { self.first(test,:end,:k) }
multi method last-index(Mu \test) {
DEPRECATED('first(:end,:k)');
self.first(test,:end,:k)
}
}

BEGIN Attribute.^compose;
Expand Down Expand Up @@ -1425,12 +1439,12 @@ multi sub sort($cmp, +values) {
!! (|$cmp,|values).sort;
}

# DEPRECATE ???
proto sub grep-index(|) {*}
multi sub grep-index(Bool:D $t, |) {
fail X::Match::Bool.new(type => 'grep-index');
}
multi sub grep-index(Mu $test, +values) {
DEPRECATED('grep(:k)');
my $laze = values.is-lazy;
values.grep($test,:k).lazy-if($laze)
}
Expand All @@ -1440,6 +1454,7 @@ multi sub first-index(Bool:D $ , |) {
fail X::Match::Bool.new(type => 'first-index');
}
multi sub first-index(Mu $test, +values) {
DEPRECATED('first(:k)');
my $laze = values.is-lazy;
values.first($test,:k).lazy-if($laze)
}
Expand All @@ -1449,6 +1464,7 @@ multi sub last-index(Bool:D $ , |) {
fail X::Match::Bool.new(type => 'last-index');
}
multi sub last-index(Mu $test, +values) {
DEPRECATED('first(:end,:k)');
my $laze = values.is-lazy;
values.first($test,:end,:k).lazy-if($laze)
}
Expand Down

0 comments on commit c589177

Please sign in to comment.