3 ms·
For no null is he saying that everything is just initialized to a default value (int=0, str=“”, etc)? I’m thrown off by, “everything is initialized to empty val
by duncan-donuts 8y ago
For no null is he saying that everything is just initialized to a default value (int=0, str=“”, etc)? I’m thrown off by, “everything is initialized to empty values” because I don’t see how empty and null are different.
- eridius 8y agoThe difference is all values are valid. In C, you can't know that a `char *` is safe to dereference.
- dkersten 8y agoGarbage but valid values are, in my opinion, much harder errors to catch because they can silently corrupt data, than a simple crash/null pointer exception. I'm not a fan of null (option types seem better -- which V does say it has), but defaulting to an "empty" value isn't the answer IMHO as it makes it much harder to debug by obscuring that there's a problem at all. You may not realise that the 0 is actually an "empty" and not a valid 0 until you realise all of your calculations are wrong, months later.
- amedvednikov 8y agoRight, the only syntax for variable declaration is a := val, so you are forced to initialize variables.