From f7c0c0bcc9543117160b0607c8f380da5dff904c Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Thu, 19 Feb 2009 23:09:29 +0100 Subject: [PATCH] move Str.reverse to setting/ I have no idea why reverse($str) still works, but it does. --- build/Makefile.in | 1 + src/classes/Str.pir | 16 +--------------- src/setting/Str.pm | 11 +++++++++++ 3 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 src/setting/Str.pm diff --git a/build/Makefile.in b/build/Makefile.in index 98d3a596e38..f2fdbc869ae 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -110,6 +110,7 @@ SETTING = \ src/setting/Bool.pm \ src/setting/List.pm \ src/setting/Pair.pm \ + src/setting/Str.pm \ src/setting/Whatever.pm \ PMCS = perl6str objectref perl6scalar mutablevar perl6multisub diff --git a/src/classes/Str.pir b/src/classes/Str.pir index 869e01d3112..24c623e2a9e 100644 --- a/src/classes/Str.pir +++ b/src/classes/Str.pir @@ -1,5 +1,3 @@ -## $Id$ - =head1 TITLE Str - Perl 6 Str class and related functions @@ -28,7 +26,7 @@ as the Perl 6 C class. p6meta.'register'('String', 'parent'=>strproto, 'protoobject'=>strproto) $P0 = get_hll_namespace ['Str'] - '!EXPORT'('sprintf,reverse', 'from'=>$P0) + '!EXPORT'('sprintf', 'from'=>$P0) .end @@ -49,18 +47,6 @@ as the Perl 6 C class. .end -.sub 'reverse' :method :multi('String') - .local pmc retv - - retv = self.'split'('') - retv = retv.'reverse'() - retv = retv.'join'('') - - .return(retv) -.end - - - =item perl() Returns a Perl representation of the Str. diff --git a/src/setting/Str.pm b/src/setting/Str.pm new file mode 100644 index 00000000000..db18a08a51d --- /dev/null +++ b/src/setting/Str.pm @@ -0,0 +1,11 @@ +class Str is also { + our Bool multi method ACCEPTS ($topic) { + self eq $topic; + + } + our Str multi method reverse ($str: ) { + return $str.split('').reverse.join; + } +} + +# vim: ft=perl6