Skip to content

Commit

Permalink
Make zprintf actually produce correct values
Browse files Browse the repository at this point in the history
Looks like I forgot to change the calling semantics of zprintf to
Formatter.  Note: "zprintf" is a temporary invention to be able
to use legacy sprintf and new Formatter based logic side-by-side
in the same language version.
  • Loading branch information
lizmat committed Jun 29, 2023
1 parent 5deb9ee commit 2e53c87
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/core.e/Format.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,19 @@ my class Format is Str {

# the procedural frontend of sprintf functionality
multi sub sprintf(Format:D $format, *@args) { # until zprintf gone
$format(@args)
$format(|@args)
}

proto sub zprintf($, |) {*}
multi sub zprintf(Str(Cool) $format, \value) {
Formatter.new($format)(nqp::list(value))
Formatter.new($format)(value)
}
multi sub zprintf(Str(Cool) $format, @args) {
Formatter.new($format)(@args)
}
multi sub zprintf(Str(Cool) $format, *@args) {
Formatter.new($format)(@args)
}
multi sub zprintf(Format:D $format, *@args) {
$format(@args)
multi sub zprintf(Str(Cool) $format, |c) {
Formatter.new($format)(|c)
}

augment class Cool {
method zprintf(*@args) { zprintf(self, @args) }
method zprintf(|c) { zprintf(self,|c) }
}

# vim: expandtab shiftwidth=4

0 comments on commit 2e53c87

Please sign in to comment.