Skip to content

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

Comments

What do other Python implementations use? If it's something that indirectly keeps track of data location it's a pointer. The actual implementation of the pointer doesn't matter.

"Call-by-object-sharing" is better expressed as "call-by-object-pointer-value". But at this point it's just an argument over definitions. One either accepts that call-by-reference and call-by-value are the only two options along with the test above that includes C++, Ada, and Pascal as languages which support call-by-reference, or one doesn't.

One either accepts that call-by-reference and call-by-value are the only two options

I do not, there is also call by need and call by name. How does your test apply to Haskell? Incidentally call by sharing is much older than python. Wikipedia claims Liskov coined the term in 1974. I agree with you, call by value where the value happens to be a reference doesn't seem fundamentally different than call by value and probably doesn't need its own term.

http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sha...

To add to the historical point, Pascal was made in 1970 and supports both call-by-value and call-by-reference, so I get the feeling that Liskov was just muddying the waters. Considering that in modern usage call-by-sharing is relatively unheard of (sometimes even in Python circles), I really don't see what it has going for it.

Can Haskell pass the test? If it can't, it doesn't support call-by-reference.

You do bring up an interesting line of thought with call-by-need et al. I tend to just lump them under "lazy evaluation" and I don't really view them as impacting the value/reference dichotomy. The question there, then, is at the end of the day if/when an argument is evaluated (to whatever extent), does it match call-by-value or call-by-reference semantics? (And if the behavior is achieved with macro expansion, can it even rightfully be called a "call-by-X" behavior?) Clojure is adamantly call-by-value with its lazy evaluation, is there any particular reason why another language couldn't have the same lazy evaluation semantics as Clojure but support call-by-reference? pdw elsewhere in this thread suggests this whole "call-by-X" issue is pointless once you bring in lazy evaluation, I don't think that's a bad assessment.

AboutSource Built by g1lg1l

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