A question on modification of a list via a function invocation

breamoreboy at gmail.com breamoreboy at gmail.com
Mon Sep 4 05:15:54 EDT 2017


On Monday, September 4, 2017 at 3:20:22 AM UTC+1, Chris Angelico wrote:
> On Mon, Sep 4, 2017 at 12:05 PM, Steve D'Aprano wrote:
> > On Mon, 4 Sep 2017 04:15 am, Stephan Houben wrote:
> >
> >> Needless to say, according to the definition in Plotkin's paper, Python
> >> is "call-by-value".
> >
> > According to Plotkin's definition, when you pass a value like a 100MB string:
> >
> > "This is a long string of text..."  # continues on for millions more characters
> >
> > does the interpreter make a copy of the 100MB string?
> >
> > If not, then it isn't pass (call) by value.
> 
> This is another proof that you can't divide everything into "pass by
> value" vs "pass by reference", unless you mess around with "passing a
> reference by value" or other shenanigans. In C, a string is not an
> entity; it's simply an array of characters. Arrays are never passed by
> value; yet everything in C is passed by value. So you pass a
> pointer... by value.
> 
> What would you define LISP's semantics as? Pass by value? Pass by
> reference? Pass by name? Pass by immutability? Pass the salt?
> 
> ChrisA

I can't say that I'm too bothered about all this what with "Practicality beats purity" and all that.  Still for the definitive guides to Python I always go back to http://effbot.org/zone/call-by-object.htm and https://jeffknupp.com/blog/2012/11/13/is-python-callbyvalue-or-callbyreference-neither/

Kindest regards.

Mark Lawrence.



More information about the Python-list mailing list