r...@zedat.fu-berlin.de (Stefan Ram): > Marko Rauhamaa <ma...@pacujo.net> writes: >>r...@zedat.fu-berlin.de (Stefan Ram): >>>Marko Rauhamaa <ma...@pacujo.net> writes: >>>>swap(slot_ref(locals(), "x"), slot_ref(locals(), "y")) >>>You need to be able to write the call as >>>swap( x, y ) >>Why? > > You responded to Bart: > > | swap(x,y) > | print (x,y) # "Z" and "10" > | > |If not, then it doesn't have reference passing as > |it is normally understood. > > , and Bart required this form. Moreover, if you allow other > forms, such as > > swap( &x, &y ) > > , then even C, would have "call by reference", > but it has not.
There's two things: syntax and semantics. Obviously, Bart's syntax couldn't work syntactically unless Python added the syntactic facilities. But the bigger question is a semantic one: is it possible regardless of syntactic considerations. As Chris pointed out, Python has explicitly ruled it out with the immutability caveat to locals(). Marko -- https://mail.python.org/mailman/listinfo/python-list