Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify DEPRECATED / is DEPRECATED for now
Before, I was thinking of having sub DEPRECATED figure out what is was warning
for, with using callframe().  But this proved to be very fragile.  So instead,
sub DEPRECATED now just gets the old and new name, and the "is DEPRECATED"
trait adds a closure in the form of once block in an ENTER phaser for the
routine.  For this to work inside routines without explicit ENTER blocks,
the time that "finish_code_object" in Actions.nqp is called, must be changed.
But I'll leave that for tomorrow.
  • Loading branch information
lizmat committed Sep 25, 2013
1 parent ddf3222 commit 6ff75a5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/core/Cool.pm
Expand Up @@ -105,12 +105,12 @@ my class Cool { # declared in BOOTSTRAP
}

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

method capitalize() { # is DEPRECATED doesn't work in settings
once DEPRECATED('tclc');
once DEPRECATED('Method Cool.capitalize', 'tclc');
self.Stringy.tclc;
}
method wordcase() { self.Str.wordcase }
Expand Down Expand Up @@ -227,16 +227,16 @@ 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');
once DEPRECATED("Sub 'ucfirst'", "'tc'");
$s.tc;
}
proto sub capitalize($) { * }
multi sub capitalize(Str:D $x) { # is DEPRECATED doesn't work in settings
once DEPRECATED('tclc');
once DEPRECATED("Sub 'capitalize'", "'tclc'");
$x.tclc;
}
multi sub capitalize(Cool $x) { # is DEPRECATED doesn't work in settings
once DEPRECATED('tclc');
once DEPRECATED("Sub 'capitalize'", "'tclc'");
$x.Stringy.tclc;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Str.pm
Expand Up @@ -782,7 +782,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
}

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

sub DEPRECATED ($changeto) {
warn "please change to $changeto";
sub DEPRECATED ( $old, $new ) is hidden_from_backtrace {
warn "$old has been deprecated, please use $new instead";
}

# Re-parent meta-objects so they appear to be under Any.
Expand Down
11 changes: 10 additions & 1 deletion src/core/traits.pm
Expand Up @@ -94,7 +94,16 @@ multi trait_mod:<is>(Routine:D $r, :$default!) {
$r does role { method default() { True } }
}
multi trait_mod:<is>(Routine:D $r, :$DEPRECATED!) {
$r.add_phaser( 'ENTER', -> { once DEPRECATED($DEPRECATED) } );
my $old = $r.WHAT ~~ Method
# ?? "Method {nqp::getattr($r,'Routine','$!package')}.{$r.name}"
?? "Method '{$r.name}'" # getattr for package fails
!! "Sub '{$r.name}'";
my $new = $DEPRECATED ~~ Bool
?? "something else"
!! $DEPRECATED;
$r.add_phaser( 'ENTER', -> {
once DEPRECATED($old, $new);
} );
}
multi trait_mod:<is>(Routine:D $r, Mu :$inlinable!) {
$r.set_inline_info(nqp::decont($inlinable));
Expand Down

0 comments on commit 6ff75a5

Please sign in to comment.