hare

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

commit 3363b79377b5361aead757769f12d394b94b3ee7
parent a3faae6f4b50c5b456a0be5ecc939f87f588ec95
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon,  1 Feb 2021 12:30:23 -0500

fmt: new module (WIP)

Diffstat:
Afmt/fmt.ha | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -0,0 +1,22 @@ +// A format string consists of a string of literal characters, to be printed +// verbatim, and format sequences, which describe how to format arguments from +// a set of variadic parameters for printing. +// +// A format sequence is enclosed in curly braces '{}'. An empty sequence takes +// the next argument from the parameter list, in order. A specific parameter can +// be used by numbering it from zero: '{0}', '{1}', and so on. A colon may be +// used to specify additional constraints on the format in a type-specific +// manner: '{0:x} will print a number in hexadecimal. +// +// TODO: Document this more I guess +use io; +use types; + +// Tagged union of all types which are formattable. +export type formattable = (...types::numeric | uintptr | str | *void); + +// Formats text for printing and writes it to an [io::stream]. +export fn fprintf(s: *io::stream, fmt: str, + args: formattable...) (io::error | size) = { + return io::unsupported: io::error; // TODO: Blocked on rune picking +};