My thought on references in Object Orientated Programming.
A reference is free or fixed:
- I fixed reference can not be reassigned.
e.g. reference in (C++), const pointer (C++), reference in functional language. - A free reference can be reassigned.
e.g. pointer in (C++), reference in (C#, Java, python …)
A reference is:
- not null-able: Can point to a valid object: e.g. Eiffel reference.
- union: Can point to a valid object, of one of a specified list of types.
- null-able: Can point to a valid object or null. e.g. Java, C#, python, Traditional Eiffel, Eiffel null-able reference.
- radical: Can point anywhere, can point to garbage or invalid memory e.g. pointer, and even a reference in (C++).
A reference refers to something that is:
- Constant: all references in functional language.
- Mutable.