by hgoel · 7mo ago · 0 comments
So, in pseudocode
int div(int a, int b): return a / b;
Would probably be a compile time error, but
int div(int a, int b): return b == 0 ? ERR : (a /b);
Would not, or at least that's what I'd expect.
The whole things looks vibe-coded, and vibe-designed.
Yes there is. Dependently typed languages like Idris can inspect terms at the value-level during compile time. Rather, instead of proving that the divisor will be zero, you must instead statically prove that the divisor cannot be zero; otherwise the code will not typecheck.
int integer_division(int a, int b) { if (b!=0) return a/b; raise(SIGFPE); }
Great.