Skip to content

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

Comments

> they will probably have some serious misconceptions about what happens when you pass an object to a function.

    p = Person()
The thing on the left is object reference, the thing on the right is object. When you do some_func(p) or some_func(Person()), you don't pass an object but an object reference.

There. No serious misconceptions.

C# and Java are doing just fine having the same model and explaining it the same way. And C programmers just need to think of `p = Person()` as `Person *p = new_person()`

>There. No serious misconceptions.

Well, yes, there might be. Because "object reference" sounds a lot like you're saying it's call-by-reference, and that's also confusing. it makes it sound like the output of this would be "overwritten":

  def some_func(x): x = "overwritten"
  p = Person()
  some_func(p)
  print p
In addition, my point was that using the term "call-by-value" is confusing, and since you didn't use that term in your explanation, it's all moot.

My point is writing a blog post saying python is neither call-by-value nor call-by-reference is made up shit and does nothing for someone who doesn't already understand it. Someone who doesn't already understand it will have to work through to get the gist of call-by-value and object references.

The blog post didn't simplify anything for someone who doesn't already understand it. So why not stick with terminology which is used by Java, C#, C among others?

>My point is writing a blog post saying python is neither call-by-value nor call-by-reference is made up shit

I guess so, in the sense that all of those terms are "made up shit". But they are useful for explaining the concepts.

>The blog post didn't simplify anything for someone who doesn't already understand it. So why not stick with terminology which is used by Java, C#, C among others?

Apparently, as others have pointed out here, the term "call-by-sharing" has largely come into popular use from people explaining how Python works in user groups. That's a strong indication that it actually is a pretty effective way to help newbies understand it.

AboutSource Built by g1lg1l

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