logoalt Hacker News

mrkeenyesterday at 1:32 PM2 repliesview on HN

Right, but I don't care about the reference to foo (that's a low-level detail that should be confined to systems languages, not application languages) I was asking about the foo.


Replies

jibaltoday at 3:10 AM

foo is a name. It's not at all clear what you mean by "the foo" ... the called function can modify the object referenced by the symbol foo unless it's immutable. If this is your complaint, then solve it with documentation ... I never write a function, in any language, that modifies anything--via parameter or in an outer scope--without documenting it as doing so.

> I don't care about the reference to foo (that's a low-level detail that should be confined to systems languages, not application languages)

This is not true at all. There's a big difference, for instance, between assigning a reference and assigning an object ... the former results in two names referring to the same object, whereas in the latter case they refer to copies. I had a recent case where a bug was introduced when converting Perl to Python because Perl arrays have value semantics whereas Python lists have reference semantics.

There seem to be disagreements here due entirely to erroneous or poor use of terminology, which is frustrating ... I won't participate further.

show 1 reply
kstrauseryesterday at 1:36 PM

Right, but that reference is all the function has. It can’t destroy another scope’s reference to the foo, and the Python GC won’t destroy the foo as long as a reference to it exists.

The function could mutate foo to be empty, if foo is mutable, but it can’t make it not exist.

show 1 reply