hare

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

commit 3d269ac418c31cc959fcb025265f0995400919ae
parent bcd4e45630aec0714b62f560b13d9f8c48f1a53b
Author: Sebastian <sebastian@sebsite.pw>
Date:   Wed, 31 May 2023 01:05:39 -0400

all: reorder tagged union fields to put error last

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mbufio/buffered.ha | 2+-
Mbufio/memstream.ha | 2+-
Mfmt/fmt.ha | 24++++++++++++------------
Mio/copy.ha | 6+++---
Mnet/ip/ip.ha | 10+++++-----
Mos/exec/cmd.ha | 2+-
6 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/bufio/buffered.ha b/bufio/buffered.ha @@ -86,7 +86,7 @@ export fn buffered( }; // Flushes pending writes to the underlying stream. -export fn flush(s: io::handle) (io::error | void) = { +export fn flush(s: io::handle) (void | io::error) = { let s = match (s) { case let st: *io::stream => if (st.writer != &buffered_write) { diff --git a/bufio/memstream.ha b/bufio/memstream.ha @@ -203,7 +203,7 @@ fn seek( return s.pos: io::off; }; -fn copy(dest: *io::stream, src: *io::stream) (io::error | size) = { +fn copy(dest: *io::stream, src: *io::stream) (size | io::error) = { if (src.reader != &read || src.writer == null) { return errors::unsupported; }; diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -24,21 +24,21 @@ export type formattable = (...types::numeric | uintptr | str | rune | bool | nullable *void | void); // 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 @@ -79,28 +79,28 @@ export fn fprintfln( h: io::handle, fmt: str, args: field... -) (io::error | size) = { +) (size | io::error) = { return 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 @@ -124,13 +124,13 @@ 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) = { return fprint(h, args...)? + io::write(h, ['\n'])?; }; // 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 = modifiers { base = strconv::base::DEC, ... }; let n = 0z; for (let i = 0z; i < len(args); i += 1) { @@ -183,7 +183,7 @@ export fn fprintf( h: io::handle, fmt: str, args: field... -) (io::error | size) = { +) (size | io::error) = { let n = 0z, i = 0z; let checkunused = true; let iter = strings::iter(fmt); diff --git a/io/copy.ha b/io/copy.ha @@ -7,7 +7,7 @@ use errors; // returns zero (underread), the copy is terminated and the amount of data // copied is returned. Note that this function will never return if the source // handle is infinite. -export fn copy(dest: handle, src: handle) (error | size) = { +export fn copy(dest: handle, src: handle) (size | error) = { match (dest) { case let fd: file => if (src is file) { @@ -30,7 +30,7 @@ export fn copy(dest: handle, src: handle) (error | size) = { }; }; -fn copy_streams(dest: *stream, src: *stream) (error | size) = { +fn copy_streams(dest: *stream, src: *stream) (size | error) = { match (dest.copier) { case null => void; case let c: *copier => @@ -48,7 +48,7 @@ fn copy_streams(dest: *stream, src: *stream) (error | size) = { return copy_fallback(dest, src); }; -fn copy_fallback(dest: handle, src: handle) (error | size) = { +fn copy_fallback(dest: handle, src: handle) (size | error) = { let w = 0z; let buf: [4096]u8 = [0...]; for (true) { diff --git a/net/ip/ip.ha b/net/ip/ip.ha @@ -161,7 +161,7 @@ export fn parse(s: str) (addr | invalid) = { return invalid; }; -fn fmtv4(s: io::handle, a: addr4) (io::error | size) = { +fn fmtv4(s: io::handle, a: addr4) (size | io::error) = { let ret = 0z; for (let i = 0; i < 4; i += 1) { if (i > 0) { @@ -172,7 +172,7 @@ fn fmtv4(s: io::handle, a: addr4) (io::error | size) = { return ret; }; -fn fmtv6(s: io::handle, a: addr6) (io::error | size) = { +fn fmtv6(s: io::handle, a: addr6) (size | io::error) = { let ret = 0z; let zstart: int = -1; let zend: int = -1; @@ -293,7 +293,7 @@ fn masklen(addr: []u8) (void | size) = { return n; }; -fn fmtmask(s: io::handle, mask: addr) (io::error | size) = { +fn fmtmask(s: io::handle, mask: addr) (size | io::error) = { let ret = 0z; let slice = match (mask) { case let v4: addr4 => @@ -315,7 +315,7 @@ fn fmtmask(s: io::handle, mask: addr) (io::error | size) = { return ret; }; -fn fmtsubnet(s: io::handle, subnet: subnet) (io::error | size) = { +fn fmtsubnet(s: io::handle, subnet: subnet) (size | io::error) = { let ret = 0z; ret += fmt(s, subnet.addr)?; ret += fmt::fprintf(s, "/")?; @@ -324,7 +324,7 @@ fn fmtsubnet(s: io::handle, subnet: subnet) (io::error | size) = { }; // Formats an [[addr]] or [[subnet]] and prints it to a stream. -export fn fmt(s: io::handle, item: (...addr | subnet)) (io::error | size) = { +export fn fmt(s: io::handle, item: (...addr | subnet)) (size | io::error) = { match (item) { case let v4: addr4 => return fmtv4(s, v4)?; diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -79,7 +79,7 @@ export @noreturn fn exec(cmd: *command) void = { }; // Starts a prepared command in a new process. -export fn start(cmd: *command) (error | process) = { +export fn start(cmd: *command) (process | error) = { defer finish(cmd); match (platform_start(cmd)) { case let err: errors::error =>