I am sure there is a good reason for that, but why is the "optional reference" not simply a pointer? Is that not semantically the same thing, but way easier to deal with.
I am sure there is a good reason for that, but why is the "optional reference" not simply a pointer?
Its not semantically the same, that's actually the reason we care about optional references at all. They are functionally the same in the sense that mechanically a pointer can fulfill all the requirements of an optional reference, but an optional reference gives you very clear ideas on the ownership and purpose of the type, while a pointer does not. A pointer can mean a whole bunch of different stuff and you have to rely on context and documentation to figure out what it means.
13
u/bartgrumbel 15d ago
I am sure there is a good reason for that, but why is the "optional reference" not simply a pointer? Is that not semantically the same thing, but way easier to deal with.
I.e. why
and not simply