Op 27-09-17 om 09:38 schreef Steven D'Aprano: No, the model that C++ and Pascal use is not different in this aspect.
> that Pascal var parameters and C++ reference variables operate the same > way as Python variable assignment, the *kindest* thing I can say is that > you are ignorant. The kindest thing I can say about you is that you are very confused at a specific level. A confusion that is illustrated by your contribution at https://mail.python.org/pipermail/python-list/2017-September/726513.html and of which you seem to totally ignore my resonse at https://mail.python.org/pipermail/python-list/2017-September/726527.html > Python does not have anything like C++ references and Pascal var > parameters, which is why you will never be able to write a swap() > function that operates like the classic Pascal swap procedure used as the > definitive test for pass-by-reference. You keep repeating this and you keep ignoring my counter argument. The fact that you can write a swap procedure in C++ and Pascal is not because the parameter passing semantics are different but because the assignment semantics are different. I already explained that a working swap function depends on two conditions: 1) Reference paramaters 2) A general way in which the object a name refers to can be modified/mutated (In a language like Pascal that is the assignment). You keep asserting that not being able to write a swap means we don't have condition (1), while ignoring we know we don't have condition (2) in Python. > Twice you have claimed to be able to write such a swap procedure for > lists. You can't. If you think you can, it is only because you have > misunderstood the problem and are writing something else that does > something different from what the Pascal version does. I already posted code once, here it is again: ls1 = [1, 3, 5, 7] ls2 = [2, 4, 6] def list_swap(lp1, lp2): tmp = [] # pseudo declaration tmp[:] = lp1 # lp1[:] = lp2 # This is more or less how array assignments work in Pascal lp2[:] = tmp # print("ls1 =", ls1) print("ls2 =", ls2) list_swap(ls1, ls2) print() print("ls1 =", ls1) print("ls2 =", ls2) -- https://mail.python.org/mailman/listinfo/python-list