Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Couldn't we do an optional type with the type system as is rather than embedding in the language?

type Optional[V any] struct { IsSet bool Value V }



The type system would store it at compile time, while your type would only have it at runtime.


How does that prevent an unset Value from being used?




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: