4 ms·
I was with you until "you cannot use references." Why not?
by thestoicattack 8y ago
I was with you until "you cannot use references." Why not?
- muro 8y agoOnce you allow only pointers, you know if you see foo.bar, foo is a value on the stack. As a function parameter, you know that mutable calls with "." don't change state outside of the function. It reduces mental overhead.
- thestoicattack 8y agoThat's a good point. I use references, even with that mental overhead, because they're not nullable. Clearly there are trade-offs.
- muro 8y agoI think const ref is ok, but avoid non-const
- gnulinux 8y agoI have nothing particularly against references, especially since they look nicer with function pointers. But, you can do everything with pointers alone and if you open the gates of hell.. erm I mean C++ then there will be countless questions about lvalue references, rvalue references whether it's ok to use T&& whether it's ok to use std::forward, std::move etc... It's just simpler to stick to pointers.