Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deprecate .uniq in favor of .unique
  • Loading branch information
lizmat committed Oct 26, 2014
1 parent 5513af3 commit d44f431
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/core/Any.pm
Expand Up @@ -56,7 +56,6 @@ my class Any { # declared in BOOTSTRAP
method Parcel() { self.list.Parcel }
method elems() { self.list.elems }
method end() { self.list.end }
method uniq(|c) { self.list.uniq(|c) }
method squish(|c) { self.list.squish(|c) }
method rotor(|c) { self.list.rotor(|c) }
method reverse() { self.list.reverse }
Expand All @@ -69,6 +68,12 @@ my class Any { # declared in BOOTSTRAP
method combinations(|c) { self.list.combinations(|c) }
method permutations(|c) { self.list.permutations(|c) }

method unique(|c) { self.list.unique(|c) }
method uniq(|c) {
DEPRECATED('unique', |<2014.11 2015.11>);
self.unique(|c);
}

proto method pick(|) { * }
multi method pick() { self.list.pick }
multi method pick($n) { self.list.pick($n) }
Expand Down
2 changes: 1 addition & 1 deletion src/core/Exception.pm
Expand Up @@ -622,7 +622,7 @@ my class X::Undeclared::Symbols does X::Comp {
}
method message(X::Undeclared::Symbols:D:) {
sub l(@l) {
my @lu = @l.map({ nqp::hllize($_) }).uniq.sort;
my @lu = @l.map({ nqp::hllize($_) }).unique.sort;
'used at line' ~ (@lu == 1 ?? ' ' !! 's ') ~ @lu.join(', ')
}
sub s(@s) {
Expand Down
15 changes: 10 additions & 5 deletions src/core/List.pm
Expand Up @@ -458,8 +458,13 @@ my class List does Positional { # declared in BOOTSTRAP
$tpos >= +$tseq;
}

proto method uniq(|) {*}
multi method uniq() {
method uniq(|c) {
DEPRECATED('uniq', |<2014.11 2015.11>);
self.unique(|c);
}

proto method unique(|) {*}
multi method unique() {
my $seen := nqp::hash();
my str $target;
gather map {
Expand All @@ -473,7 +478,7 @@ my class List does Positional { # declared in BOOTSTRAP
}
}, @.list;
}
multi method uniq( :&as!, :&with! ) {
multi method unique( :&as!, :&with! ) {
my @seen; # should be Mu, but doesn't work in settings :-(
my Mu $target;
gather map {
Expand All @@ -487,7 +492,7 @@ my class List does Positional { # declared in BOOTSTRAP
}
}, @.list;
}
multi method uniq( :&as! ) {
multi method unique( :&as! ) {
my $seen := nqp::hash();
my str $target;
gather map {
Expand All @@ -501,7 +506,7 @@ my class List does Positional { # declared in BOOTSTRAP
}
}, @.list;
}
multi method uniq( :&with! ) {
multi method unique( :&with! ) {
nextwith() if &with === &[===]; # use optimized version

my @seen; # should be Mu, but doesn't work in settings :-(
Expand Down
7 changes: 6 additions & 1 deletion src/core/Supply.pm
Expand Up @@ -206,7 +206,12 @@ my role Supply {
}
}

method uniq(Supply:D $self: :&as, :&with, :$expires) {
method uniq(Supply:D: |c) {
DEPRECATED('unique', |<2014.11 2015.11>);
self.unique(|c);
}

method unique(Supply:D $self: :&as, :&with, :$expires) {
on -> $res {
$self => do {
if $expires {
Expand Down
2 changes: 1 addition & 1 deletion src/core/signals.pm
Expand Up @@ -6,7 +6,7 @@ sub signal(Signal $signal, *@signals, :$scheduler = $*SCHEDULER) {
die "Found invalid signals: {@invalid}";
}
@signals.unshift: $signal;
@signals .= uniq;
@signals .= unique;

state %sigmap =
SIGINT, nqp::const::SIG_INT,
Expand Down

0 comments on commit d44f431

Please sign in to comment.