lang: rename signed integer types sN -> iN
Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.
Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).
Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.
zig build test: 426/426; examples suite: 595/595.
This commit is contained in:
@@ -12,14 +12,14 @@ wrapped around them. A function that can fail adds a trailing `!` to its
|
||||
return type:
|
||||
|
||||
```sx
|
||||
parse_digit :: (s: string) -> (s32, !) {
|
||||
parse_digit :: (s: string) -> (i32, !) {
|
||||
if s.len == 0 raise error.Empty;
|
||||
if !is_digit(s[0]) raise error.BadDigit;
|
||||
return s[0] - '0';
|
||||
}
|
||||
```
|
||||
|
||||
The `(s32, !)` says "returns an `s32` on success, or an error." The `!`
|
||||
The `(i32, !)` says "returns an `i32` on success, or an error." The `!`
|
||||
is one more slot in sx's normal multi-return — the error rides
|
||||
alongside the values, it doesn't replace them.
|
||||
|
||||
@@ -61,7 +61,7 @@ in the signature:
|
||||
```sx
|
||||
ParseErr :: error { Empty, BadDigit, Overflow };
|
||||
|
||||
parse_int :: (s: string) -> (s32, !ParseErr) {
|
||||
parse_int :: (s: string) -> (i32, !ParseErr) {
|
||||
if s.len == 0 raise error.Empty;
|
||||
if overflowed raise error.Overflow;
|
||||
...
|
||||
@@ -109,7 +109,7 @@ When you call a failable function and want its error to bubble up to
|
||||
*your* caller, prefix the call with `try`:
|
||||
|
||||
```sx
|
||||
two_digits :: (s: string) -> (s32, !) {
|
||||
two_digits :: (s: string) -> (i32, !) {
|
||||
a := try parse_digit(s); // if this fails, two_digits fails
|
||||
b := try parse_digit(s[1..]);
|
||||
return a * 10 + b;
|
||||
@@ -153,7 +153,7 @@ attempt.
|
||||
port := parse_port(s) or 8080; // if parsing fails, port = 8080
|
||||
```
|
||||
|
||||
The error is absorbed; `port` is a plain `s32`.
|
||||
The error is absorbed; `port` is a plain `i32`.
|
||||
|
||||
### Chain attempts — first success wins
|
||||
|
||||
@@ -347,7 +347,7 @@ For human-readable context, use `log` on the error path — the tag tells
|
||||
you *what* failed, the log tells you the *details*:
|
||||
|
||||
```sx
|
||||
parse :: (s: string) -> (s32, !) {
|
||||
parse :: (s: string) -> (i32, !) {
|
||||
onfail e { log.warn("parsing {}: {}", s, e); }
|
||||
...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user