5 ms·
I've wanted a language like this. Java's checked exceptions with some way to offload the bookkeeping to the compiler. What about other run-time exceptions, li
by ajennings 8y ago
I've wanted a language like this. Java's checked exceptions with some way to offload the bookkeeping to the compiler.
What about other run-time exceptions, like divide by zero? Are they checked?
What about Hoare's billion-dollar mistake (null pointer exceptions)? Does Zig have non-nullable references?
- AndyKelley 8y agoZig has a bunch of runtime safety checking. It applies to divide by zero as well as integer overflow, using the wrong union field, and many more. The runtime safety checks are enabled in Debug and ReleaseSafe mode and disabled in ReleaseFast and ReleaseSmall mode. (Actually they are used as assertions to the optimizer so that it can rely on extra stuff being undefined behavior.) Pointers can not be null. However you can have optional pointers which are guaranteed to use the 0x0 value as null and have the same size as normal pointers.
- deleted 8y ago[deleted]