Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
90s_dev
· 1y ago · 0 comments
C has non-nullable types too. Only one type can be null in C, and in that event it signifies an absence of a value of that type.
Comments
[–]
freeone3000
1y ago
Sure, but practically, that type is used
so commonly
that such a distinction is useless. Can I get a FILE? I guess I can get a FILE*…
[–]
90s_dev
OP
1y ago
Right, so check if it's null. In practice, you do it just as often in C as you check for std::nullopt in C++ or std::option::ok in Rust etc.
[–]
remexre
1y ago
Once I check if an Option/optional/Maybe is none, I can extract the value and just pass around the value, so other functions I call know that the value cannot be null.
This does not work well for FILE in C, for instance.