Hacker News new | past | comments | ask | show | jobs | submit login

swap(ref a, ref b) would be all it takes in C#. Or am I missing something? Huge difference between that and pointers in C.



The reason I would argue this isn't call-by-reference is because of the additional syntax needed from the caller side. Similarly with C you can do swap(&a, &b). In C++ you just need swap(a, b), it's up to the callee whether a and b are passed as references or not.


I understand, now. You're taking an object and getting a reference to it, then passing the _value_ of that reference into the function you're calling, so it's still call-by-value where the value happens to have a semantic meaning as a reference to an object.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: