New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of Str.sprintf. #140
Labels
Comments
From @bacekHello. There is implementation of sprintf. Only src/classes/Str.pir affected. BTW, '%p' works in parrot, but according to S29 shouldn't. -- |
From @bacekstr.diffdiff --git a/languages/perl6/src/classes/Str.pir b/languages/perl6/src/classes/Str.pir
index 0bd0d95..6195989 100644
--- a/languages/perl6/src/classes/Str.pir
+++ b/languages/perl6/src/classes/Str.pir
@@ -213,6 +213,14 @@ as the Perl 6 C<Str> class.
.return(retv)
.end
+.sub 'sprintf' :method
+ .param pmc args :slurpy
+ .local pmc retv
+
+ retv = new 'Perl6Str'
+ retv = sprintf self, args
+ .return (retv)
+.end
=item perl()
@@ -427,6 +435,23 @@ Returns string with one Char removed from the end.
.return s.'chop'()
.end
+=item sprintf
+
+ our Str multi method sprintf ( Str $format: *@args ) is export
+
+This function is mostly identical to the C library sprintf function.
+
+=cut
+
+.sub 'sprintf'
+ .param pmc format
+ .param pmc args :slurpy
+ .local pmc s
+ s = new 'Perl6Str'
+ s = format
+ .return s.'sprintf'(args :flat)
+.end
+
=back
=head2 TODO Functions
@@ -480,8 +505,6 @@ Needs to be in terms of StrPos, not Int.
Needs to be in terms of StrPos, not Int.
-=item sprintf
-
=item unpack
=item vec
|
From @pmichaudApplied in r28627, with modifications to avoid the duplicate function sub. Thanks! Pm |
1 similar comment
From @pmichaudApplied in r28627, with modifications to avoid the duplicate function sub. Thanks! Pm |
@pmichaud - Status changed from 'new' to 'resolved' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migrated from rt.perl.org#56208 (status was 'resolved')
Searchable as RT56208$
The text was updated successfully, but these errors were encountered: