You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const eu = error{ problem1, problem2, problem3 }!u63;
const out = std.io.getStdOut().writer();
try out.print("error union size: {}\n", .{@sizeOf(eu)});
try out.print("test size: {}\n", .{@sizeOf(?u63)});
output:
error union size: 16
?u63 size: 16
Why not just store the error codes as two's complement negative integers in the same space the u63 would be stored in the error union? That way the error union size would be only 8 bytes.
In the error union, it would also be possible to try fitting in error associated-values (which were proposed in #2647), though that could involve more complexity to varying degrees. E.g. you could truncate the negative i64 error code to i32 and have room for a u32 error-associated value in this case.
Also, I know I might eventually be able to use a proposed arbitrary-range integer type as in #3806 with 0 as sentinel for absence of value, but if for some reason I wanted 0 to be a valid value while sacrificing 2^63 valid values, the absence of a value for the optional u63 could be indicated by the sign bit (MSB) being 1.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
output:
Why not just store the error codes as two's complement negative integers in the same space the
u63
would be stored in the error union? That way the error union size would be only8
bytes.In the error union, it would also be possible to try fitting in error associated-values (which were proposed in #2647), though that could involve more complexity to varying degrees. E.g. you could truncate the negative
i64
error code toi32
and have room for au32
error-associated value in this case.Also, I know I might eventually be able to use a proposed arbitrary-range integer type as in #3806 with
0
as sentinel for absence of value, but if for some reason I wanted0
to be a valid value while sacrificing2^63
valid values, the absence of a value for the optionalu63
could be indicated by the sign bit (MSB) being1
.The text was updated successfully, but these errors were encountered: