3 ms·
Wait till they start learning about C++. A notion of ‘reference’ there that is separate from that of ‘pointer‘ confuses things even more.
by Koshkin 6y ago
Wait till they start learning about C++. A notion of ‘reference’ there that is separate from that of ‘pointer‘ confuses things even more.
- pjmlp 6y agoNot sure why it should be confusing it goes all the way back to Algol and the languages derived from it on the Pascal/Mesa/Modula/ML family branches.
- AnimalMuppet 6y agoIt took me a minute to recall what you're referring to. To save everyone else the trouble: Pascal had pointers. And it also had var parameters, which are essentially pass-by-reference. (At least, I presume that's what pjmlp is, um, referring to...)
- pjmlp 6y agoNot only, in Ada, Modulas and Oberons you can have them as local variables as well, and in the variants with GC support, they split further into traced and untraced references.
- Koshkin 6y agoBecause in C these notions coincide.
- pjmlp 6y agoReferences are just implicit pointers, it is so hard to get them? Not sure what is so hard, then again I learned them in Basic and Pascal variants before getting to learn C.
- Koshkin 6y agoOK, first of all, the syntax and the semantics of a pointer and a reference are completely different from each other. Departing from C, one must start thinking of a pointer as a variable containing a value that is a reference, the latter now always being a constant. That's pretty subtle, I must say. Add to that a very important distinction between lvalue, rvalue, and "universal" references, and then one needs to stay very much current as a C++ coder to remember all that.
- pjmlp 6y agoAh that is what you mean, then yeah I agree.