Files
ww/lib/errors/errors.ww
Hojun-Cho 1ac1d985f6 lib: rename stdlib surface to Hare names; add endian/math
Sweeping rename so the lib/ surface mirrors Hare's stdlib spellings.
- ascii: rune-taking predicates; ishex -> isxdigit
- bufio: rinit -> init; take1/takeline -> readbyte/readline
- bytes: indexsub -> index
- encoding/utf8: runelen -> runesz
- errors: eEOF/eShortRead/... -> eof/underread/...
- fmt: errln -> errorln; println/fprintln return i64
- os: readfull/writefull -> readall/writeall; unlink -> remove
- path: isabs -> abs; drop lastindex (now strings.rbyteindex)
- strconv: u64toa/i64toa -> u64tos/i64tos; parse64/parseu64 -> stoi64/stou64
- strings: drop len/isempty; equal -> compare; indexbyte -> byteindex; +rbyteindex
- types: drop numeric helpers (moved to math)
- new lib/endian (htonu16/ntohu16), lib/math (absi32/absi64)
- net: drop htons (use endian.htonu16)

Callers in selfhost/, lib/ww/, cmd/w6c/cgen.c, and test/wcc/700_e2e.c
updated to match.
2026-05-12 00:45:18 +09:00

31 lines
943 B
Plaintext

// errors — error type (a string) and a few sentinels. Plan 9 model:
// the empty string means OK, a non-empty string is the message.
type error = str;
def eof: error = "eof";
def underread: error = "short read";
def underwrite: error = "short write";
def closed: error = "closed";
def invalid: error = "invalid argument";
def noaccess: error = "permission denied";
def noentry: error = "not found";
def exists: error = "already exists";
export fn isnil(e: error) bool = {
return e.len == 0;
};
// equal — compare an error against a sentinel (or any other error).
// Pure byte equality. (Was `errors.is` before `is` became a keyword
// for tagged-union type-tests; rename matches bytes.equal / strings.equal.)
export fn equal(e: error, want: error) bool = {
if (e.len != want.len) { return false; };
let i: i32 = 0;
for (i < e.len) {
if (e[i] != want[i]) { return false; };
i += 1;
};
return true;
};