Hi Hakki,

maybe you can comment inline as well. So everybody can see what part of
the mail you refer to.

Now as far as i can tell you are explaining the difference of call by
value and by ref and how that affects return values. I think i already
know the basics of that.

My comment just was that

value = function(ref0)

is not a good pattern when the existing code is using

value, value0 = function()

Say we did not already have the above pattern, the following would be
possible and not mixing up both

function(ref, ref0)

Now i think there were more comments, so let us take this back inline.

Henning

Am Mon, 6 May 2019 07:45:46 -0700
schrieb Hakkı Kurumahmut <[email protected]>:

> Hi Henning,
> 
> I am not a python expert. But it works because list is a mutable type.
> 
> https://stackoverflow.com/questions/986006/how-do-i-pass-a-variable-by-reference/986145#986145
> 
> Some Link content:
> 
> Arguments are passed by assignment. The rationale behind this is two
> fold:
> 
> the parameter passed in is actually a reference to an object (but the
> reference is passed by value) some data types are mutable, but others
> aren't So:
> 
> If you pass a mutable object into a method, the method gets a
> reference to that same object and you can mutate it to your heart's
> delight, but if you rebind the reference in the method, the outer
> scope will know nothing about it, and after you're done, the outer
> reference will still point at the original object.
> 
> If you pass an immutable object to a method, you still can't rebind
> the outer reference, and you can't even mutate the object.
> 
> To make it even more clear, let's have some examples.
> 
> List - a mutable type
> Let's try to modify the list that was passed to a method:
> 
> def try_to_change_list_contents(the_list):
>     print('got', the_list)
>     the_list.append('four')
>     print('changed to', the_list)
> 
> outer_list = ['one', 'two', 'three']
> 
> print('before, outer_list =', outer_list)
> try_to_change_list_contents(outer_list)
> print('after, outer_list =', outer_list)
> Output:
> 
> before, outer_list = ['one', 'two', 'three']
> got ['one', 'two', 'three']
> changed to ['one', 'two', 'three', 'four']
> after, outer_list = ['one', 'two', 'three', 'four']
> Since the parameter passed in is a reference to outer_list, not a
> copy of it, we can use the mutating list methods to change it and
> have the changes reflected in the outer scope.
> 
> 
> HAKKI
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to