logoalt Hacker News

elcritchtoday at 2:33 PM2 repliesview on HN

The compiler can still enforce checks, such as with nil checks for pointers.

In my opinion it’s overall cleaner if the compiler handles enforcing it when it can. Something like “ensure variable is initialized” can just be another compiler check.

Combined with an effects system that lets you control which errors to enforce checking on or not. Nim has a nice `forbids: IOException` that lets users do that.


Replies

ux266478today at 3:30 PM

Both of these things respectively are just pattern matches and monads, just not user-definable ones.

umanwizardtoday at 2:45 PM

> The compiler can still enforce checks, such as with nil checks for pointers.

Only sometimes, when the compiler happens to be able to understand the code fully enough. With sum types it can be enforced all the time, and bypassed when the programmer explicitly wants it to be.

show 1 reply