hare

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

commit f5dc0e9e7d7f8adeb1d775fd1127a5107acde6a9
parent 85dbdf6d332ac8dbbc69c7188b5f1c62769affff
Author: Sebastian <sebastian@sebsite.pw>
Date:   Tue, 12 Mar 2024 18:27:15 -0400

fmt: change order of tagged union return types

So the non-error result is before the error result

Diffstat:
Mfmt/print.ha | 4++--
Mfmt/wrappers.ha | 20++++++++++----------
2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fmt/print.ha b/fmt/print.ha @@ -10,7 +10,7 @@ use types; // Formats values for printing using the default format modifiers and writes // them to an [[io::handle]] separated by spaces. -export fn fprint(h: io::handle, args: formattable...) (io::error | size) = { +export fn fprint(h: io::handle, args: formattable...) (size | io::error) = { let mod = mods { ... }; let n = 0z; for (let i = 0z; i < len(args); i += 1) { @@ -27,7 +27,7 @@ export fn fprintf( h: io::handle, fmt: str, args: field... -) (io::error | size) = { +) (size | io::error) = { let n = 0z, i = 0z; let it = iter(fmt, args); for (true) match (next(&it)) { diff --git a/fmt/wrappers.ha b/fmt/wrappers.ha @@ -7,21 +7,21 @@ use os; use strings; // Formats text for printing and writes it to [[os::stdout]]. -export fn printf(fmt: str, args: field...) (io::error | size) = +export fn printf(fmt: str, args: field...) (size | io::error) = fprintf(os::stdout, fmt, args...); // Formats text for printing and writes it to [[os::stdout]], followed by a line // feed. -export fn printfln(fmt: str, args: field...) (io::error | size) = +export fn printfln(fmt: str, args: field...) (size | io::error) = fprintfln(os::stdout, fmt, args...); // Formats text for printing and writes it to [[os::stderr]]. -export fn errorf(fmt: str, args: field...) (io::error | size) = +export fn errorf(fmt: str, args: field...) (size | io::error) = fprintf(os::stderr, fmt, args...); // Formats text for printing and writes it to [[os::stderr]], followed by a line // feed. -export fn errorfln(fmt: str, args: field...) (io::error | size) = +export fn errorfln(fmt: str, args: field...) (size | io::error) = fprintfln(os::stderr, fmt, args...); // Formats text for printing and writes it into a heap-allocated string. The @@ -62,26 +62,26 @@ export fn fprintfln( h: io::handle, fmt: str, args: field... -) (io::error | size) = fprintf(h, fmt, args...)? + io::write(h, ['\n'])?; +) (size | io::error) = fprintf(h, fmt, args...)? + io::write(h, ['\n'])?; // Formats values for printing using the default format modifiers and writes // them to [[os::stdout]] separated by spaces. -export fn print(args: formattable...) (io::error | size) = +export fn print(args: formattable...) (size | io::error) = fprint(os::stdout, args...); // Formats values for printing using the default format modifiers and writes // them to [[os::stdout]] separated by spaces and followed by a line feed. -export fn println(args: formattable...) (io::error | size) = +export fn println(args: formattable...) (size | io::error) = fprintln(os::stdout, args...); // Formats values for printing using the default format modifiers and writes // them to [[os::stderr]] separated by spaces. -export fn error(args: formattable...) (io::error | size) = +export fn error(args: formattable...) (size | io::error) = fprint(os::stderr, args...); // Formats values for printing using the default format modifiers and writes // them to [[os::stderr]] separated by spaces and followed by a line feed. -export fn errorln(args: formattable...) (io::error | size) = +export fn errorln(args: formattable...) (size | io::error) = fprintln(os::stderr, args...); // Formats values for printing using the default format modifiers and writes @@ -105,5 +105,5 @@ export fn bsprint(buf: []u8, args: formattable...) str = { // Formats values for printing using the default format modifiers and writes // them to an [[io::handle]] separated by spaces and followed by a line feed. -export fn fprintln(h: io::handle, args: formattable...) (io::error | size) = +export fn fprintln(h: io::handle, args: formattable...) (size | io::error) = fprint(h, args...)? + io::write(h, ['\n'])?;