hare

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

commit 4cff751cd24fa71b88f439a19f346d481fb34def
parent 2eb4270b1f81f926fecea89388e32a101ba7270b
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Wed,  3 Mar 2021 23:35:51 -0500

io: drop now-unnecessary @init func

Diffstat:
Mio/stream.ha | 16+++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/io/stream.ha b/io/stream.ha @@ -70,17 +70,15 @@ export fn tell(s: *stream) (off | error) = { }; }; -// A [stream] which always reads EOF and discards any writes. -export let empty: *io::stream = null: *io::stream; - -// TODO: This can be removed when globals can reference other globals -@init fn init() void = { - static let s = io::stream { ... }; - s.reader = &empty_read; - s.writer = &empty_write; - empty = &s; +let _empty: io::stream = io::stream { + reader = &empty_read, + writer = &empty_write, + ... }; +// A [stream] which always reads EOF and discards any writes. +export let empty: *io::stream = &_empty; + fn empty_read(s: *stream, buf: []u8) (size | EOF | error) = EOF; fn empty_write(s: *stream, buf: const []u8) (size | error) = len(buf);