hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit e54506e432f900cc61b480288d01240c80b1ae7d
parent ed43f94582f39d7a317397c7421e24faa068c59a
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Feb 2021 20:22:18 -0500

fmt: add printf, errorf

Diffstat:
Mfmt/fmt.ha | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -11,8 +11,9 @@ // TODO: More detail use encoding::utf8; use io; -use strings; +use os; use strconv; +use strings; use types; // Tagged union of all types which are formattable. @@ -54,6 +55,14 @@ export fn fprintf( return n; }; +// Formats text for printing writes it to [os::stdout]. +export fn printf(fmt: str, args: formattable...) (io::error | size) = + fprintf(os::stdout, fmt, args...); + +// Formats text for printing writes it to [os::stderr]. +export fn errorf(fmt: str, args: formattable...) (io::error | size) = + fprintf(os::stderr, fmt, args...); + fn format(out: *io::stream, arg: formattable) void = match (arg) { s: str => io::write(out, strings::to_utf8(s)), v: *void => format(out, v: uintptr), // TODO: Hexadecimal