#WHY??

1 messages · Page 1 of 1 (latest)

quasi cedar
#

why does odin have nullable pointers instead of option type, why?
and cant i enforce it somehow.
It could've prevented the most common bug by having an optional

fossil summit
proper crag
#

Maybe is there if you want that behaviour.

quasi cedar
#

but still it makes it not clear if the value returned by this fn is guaranteed to have a valid reference and checking every single one of them is annoying

woven lily
#

most of nil pointers are bugs anyway

#

Odin also has the -> (res: ^T, ok: bool) pattern which is more ergonomic than checking the pointer

#

also, just don't return pointers

#

it's not that hard

proper crag
quasi cedar
#

the thing is if its not wraped in optional i can know for a fact that its valid if its not nullable

quasi cedar
woven lily
fossil summit
#

In any case, the language's semantics pretty much don't allow them to not possibly be nil. ZII/zero is initialized; everything is default-initialized to 0

woven lily
#

having non nil pointer will literally solve nothing and make the language much more clunky to use

#

(since odin is not designed to be memory safe)

#

i think you are being unfair in using a language not even one day and then throwing yourself at the debate about its core design

proper crag
#

-# it still might not be valid memory, but that's besides the point.

quasi cedar
quasi cedar