From a919e1dbe7919a40945aa68fd05c4a658cd168a6 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 12 Jul 2020 15:33:02 -0400 Subject: fixed bin op problems, added testing types for equality --- std/io.toc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'std/io.toc') diff --git a/std/io.toc b/std/io.toc index c61d174..10ec1d3 100644 --- a/std/io.toc +++ b/std/io.toc @@ -151,7 +151,6 @@ MODE_WRITE :: FileMode = 2; IO_DEBUG ::= base.DEBUG; -// @TODO: flush for read files -- discard buffer // @TODO: error flag // @TODO: locking? File ::= struct { @@ -247,12 +246,12 @@ fputs ::= fn(f: &File, s: []char) err : FileError { } } -writes ::= fn(s: []char) FileError { - return fwrites(&std_out, s); +writes ::= fn(s: []char) { + fwrites(&std_out, s); } -puts ::= fn(s: []char) FileError { - return fputs(&std_out, s); +puts ::= fn(s: []char) { + fputs(&std_out, s); } fwritei ::= fn(use f: &File, x: int) err : FileError { @@ -306,14 +305,20 @@ fwritei ::= fn(use f: &File, x: int) err : FileError { } } -writei ::= fn(x: int) FileError { - return fwritei(&std_out, x); +writei ::= fn(x: int) { + fwritei(&std_out, x); } -puti ::= fn(x: int) err : FileError { - err = writei(x); - if !err { - err = writes("\n"); +puti ::= fn(x: int) { + writei(x); + writes("\n"); +} + +putb ::= fn(x: bool) { + if x { + writes("true\n"); + } else { + writes("false\n"); } } -- cgit v1.2.3