hare

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

commit 6aebde2538a5d8d6c5684ab5ac4d7c8a5d7f49ab
parent b8b0327ef2249b846f9f0cde2ac4d0f17af2f9d2
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri,  5 Feb 2021 12:27:02 -0500

fmt: accept nullable *void

Diffstat:
Mfmt/fmt.ha | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -18,7 +18,8 @@ use strings; use types; // Tagged union of all types which are formattable. -export type formattable = (...types::numeric | uintptr | str | rune | *void); +export type formattable = (...types::numeric | uintptr + | str | rune | nullable *void); // Formats text for printing writes it to [os::stdout]. export fn printf(fmt: str, args: formattable...) (io::error | size) = @@ -106,5 +107,8 @@ fn format(out: *io::stream, arg: formattable) void = match (arg) { let s = strconv::uptrtos(p); io::write(out, strings::to_utf8(s)); }, - v: *void => format(out, v: uintptr), // TODO: Hexadecimal + v: nullable *void => match (v) { + v: *void => format(out, v: uintptr), // TODO: Hexadecimal + null => format(out, "(null)"), + }, };