A question on modification of a list via a function invocation

Chris Angelico rosuav at gmail.com
Sun Sep 3 22:20:00 EDT 2017


On Mon, Sep 4, 2017 at 12:05 PM, Steve D'Aprano
<steve+python at pearwood.info> 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



More information about the Python-list mailing list