Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Proof of concept for is DEPRECATED handling, in settings and outside …
…of it
  • Loading branch information
lizmat committed Sep 24, 2013
1 parent 36343bc commit f4a21d6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
29 changes: 22 additions & 7 deletions src/core/Cool.pm
Expand Up @@ -104,9 +104,15 @@ my class Cool { # declared in BOOTSTRAP
nqp::p6box_s(nqp::tclc(nqp::unbox_s(self.Str)))
}

method ucfirst() is DEPRECATED { self.tc }
method ucfirst() { # is DEPRECATED doesn't work in settings
once DEPRECATED('tc');
self.tc;
}

method capitalize() is DEPRECATED { self.Stringy.capitalize }
method capitalize() { # is DEPRECATED doesn't work in settings
once DEPRECATED('tclc');
self.Stringy.tclc;
}
method wordcase() { self.Str.wordcase }

method chomp() {
Expand Down Expand Up @@ -220,6 +226,20 @@ my class Cool { # declared in BOOTSTRAP
}
Metamodel::ClassHOW.exclude_parent(Cool);

sub ucfirst(Cool $s) { # is DEPRECATED doesn't work in settings
once DEPRECATED('tc');
$s.tc;
}
proto sub capitalize($) { * }
multi sub capitalize(Str:D $x) { # is DEPRECATED doesn't work in settings
once DEPRECATED('tclc');
$x.tclc;
}
multi sub capitalize(Cool $x) { # is DEPRECATED doesn't work in settings
once DEPRECATED('tclc');
$x.Stringy.tclc;
}

sub chop(Cool $s) { $s.chop }
sub chomp(Cool $s) { $s.chomp }
sub flip(Cool $s) { $s.flip }
Expand All @@ -228,7 +248,6 @@ sub lc(Cool $s) { $s.lc }
sub ord(Cool $s) { $s.ord }
sub substr(Cool $s,$pos,$chars?) { $s.substr($pos,$chars) }
sub uc(Cool $s) { $s.uc }
sub ucfirst(Cool $s) is DEPRECATED { $s.ucfirst }
sub tc(Cool $s) { $s.tc }
sub tclc(Cool $s) { $s.tclc }

Expand All @@ -242,10 +261,6 @@ multi sub ords(Cool $s) { ords($s.Stringy) }
proto sub comb($, $, $?) { * }
multi sub comb(Regex $matcher, Cool $input, $limit = *) { $input.comb($matcher, $limit) }

proto sub capitalize($) is DEPRECATED { * }
multi sub capitalize(Str:D $x) {$x.capitalize }
multi sub capitalize(Cool $x) {$x.Stringy.capitalize }

proto sub wordcase($) is pure { * }
multi sub wordcase(Str:D $x) {$x.wordcase }
multi sub wordcase(Cool $x) {$x.Str.wordcase }
Expand Down
3 changes: 2 additions & 1 deletion src/core/Str.pm
Expand Up @@ -781,7 +781,8 @@ my class Str does Stringy { # declared in BOOTSTRAP
nqp::encode(nqp::unbox_s(self), nqp::unbox_s($enc), nqp::decont($enc_type.new))
}

method capitalize(Str:D:) is DEPRECATED {
method capitalize(Str:D:) { # is DEPRECATED doesn't work in settings
once DEPRECATED('tclc');
self.subst(:g, rx/\w+/, -> $_ { .Str.tclc });
}
method wordcase(Str:D: :&filter = &tclc, Mu :$where = True) {
Expand Down
5 changes: 5 additions & 0 deletions src/core/core_epilogue.pm
@@ -1,3 +1,8 @@

sub DEPRECATED ($changeto) {
warn "please change to $changeto";
}

# Re-parent meta-objects so they appear to be under Any.
BEGIN {
Perl6::Metamodel::ClassHOW.HOW.reparent(Perl6::Metamodel::ClassHOW, Any);
Expand Down
4 changes: 2 additions & 2 deletions src/core/traits.pm
Expand Up @@ -6,7 +6,7 @@ my class X::Composition::NotComposable { ... }
my class X::Import::MissingSymbols { ... }
my class X::Redeclaration { ... }
my class X::Inheritance::SelfInherit { ... }
my class X::Comp::Trait::Unknown { ... };
my class X::Comp::Trait::Unknown { ... }

proto trait_mod:<is>(|) { * }
multi trait_mod:<is>(Mu:U $child, Mu:U $parent) {
Expand Down Expand Up @@ -94,7 +94,7 @@ multi trait_mod:<is>(Routine:D $r, :$default!) {
$r does role { method default() { True } }
}
multi trait_mod:<is>(Routine:D $r, :$DEPRECATED!) {
# we'll add logic here later
$r.add_phaser( 'ENTER', -> { once DEPRECATED($DEPRECATED) } );
}
multi trait_mod:<is>(Routine:D $r, Mu :$inlinable!) {
$r.set_inline_info(nqp::decont($inlinable));
Expand Down

0 comments on commit f4a21d6

Please sign in to comment.