Accname
2D-Graphics enthusiast
- Reaction score
- 1,462
Hi there,
I was having some thoughts on the design of programming languages.
I got to the conclusion, that I really hate nullpointers. In my programs I usually try to create a subclass of a class which acts as a "null" reference; a class I use if the object is not really defined.
Why do I do this? Because it makes the code shorter. Instead of having branches to check for null references, I simply overload all functions in my "null"-subclass with empty methods and default values.
Sure, this doesnt work in all situations, but in many situations it does.
So I was thinking, why not integrate something like this in the programming language itself.
Each class could define a "null"-reference for its instances. If a class does not define an own null-reference then the reference from the super class is being used.
I think this could help enormously to cut down code size and make applications more stable.
What do you guys think?
I was having some thoughts on the design of programming languages.
I got to the conclusion, that I really hate nullpointers. In my programs I usually try to create a subclass of a class which acts as a "null" reference; a class I use if the object is not really defined.
Why do I do this? Because it makes the code shorter. Instead of having branches to check for null references, I simply overload all functions in my "null"-subclass with empty methods and default values.
Sure, this doesnt work in all situations, but in many situations it does.
So I was thinking, why not integrate something like this in the programming language itself.
Each class could define a "null"-reference for its instances. If a class does not define an own null-reference then the reference from the super class is being used.
I think this could help enormously to cut down code size and make applications more stable.
What do you guys think?