4 ms·
Each language can define NULL differently. However, because eventually it gets compiled to machine code, it does indeed need to be represented by some value. Mo
by speedplane 7y ago
Each language can define NULL differently. However, because eventually it gets compiled to machine code, it does indeed need to be represented by some value. Most languages represent that value as 0, but not always.
It's better to think about NULL as a value plus a type. The value "False" may be 0 with a boolean type, just as NULL may be 0 with a pointer type.
- CGamesPlay 7y agoGolang has typed nil pointers (that is, a nil *CustomError is not equal to a nil error and so on) and it is probably the single thing that has bitten me the most in go.
- pjc50 7y agoNull is also the absence of a value altogether.
- speedplane 7y ago> Null is also the absence of a value altogether. In digital logic, there is no such thing as an "absence of a value". Everything must be represented as bits one way or another. Computers can certainly represent higher level concepts like an "absence of value", but at the lowest levels, they must be represented by some bit-stream. Types are generally the way that higher level concepts can be translated from low-level bitstreams.
- pjc50 7y agoThere certainly can be an absence of value if the value isn't there. Think serialization or sparse arrays. A null may be represented by the absence of representation.