On 5/31/2011 2:37 AM, Henry Olders wrote:
what I want is a function that is free of side effects back through
the parameters passed in the function call.
You can get that by refraining from mutating parameter objects.
Simple as that.
Just do not expect Python to enforce that discipline on everyone else.
To be really functional, and never mutate objects, do not use Python
lists, which are arrays. Use linked-list trees, like Lisp languages and
perhaps others do. One can easily do this with tuples, or a subclass of
tuples, or a class wrapping tuples.
Linked-lists and functional programming go together because prepending
to a linked list creates a new object while appending to a Python list
mutates an existing list. Similarly, popping from a linked list
retrieves an item and an existing sublist while popping from a Python
list retrieves and item and mutates the list.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list