Skip to content

Comment on Is Python call-by-value or call-by-reference? Neither.parent

Comments

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.