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?




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

Search: