4 ms·
AFAICT, that's achievable with pointers, too.
by jpr 15y ago
AFAICT, that's achievable with pointers, too.
- arghnoname 15y agoOf course it is, with the minor syntactic addition of callers passing in the memory location. References aren't a _necessary_ feature of function parameters and if the reference is going to be modified, a pointer is more clear and should be used. But there is a utility in allowing references to exist in the language for overloaded operators, so you can overload a subscript in a collection and assign to it, such as foo[x] = bar, where foo is a collection of bar objects. They could have restricted references to just these sorts of use cases and when using foo[x] as an argument, require the user to type &foo[x], but once references are in the language allowing them as parameters seems like a reasonable enough decision to me.