Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6733 > unrolled thread

Re: scope of function parameters (take two)

Started byTerry Reedy <tjreedy@udel.edu>
First post2011-05-31 11:59 -0400
Last post2011-05-31 11:59 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: scope of function parameters (take two) Terry Reedy <tjreedy@udel.edu> - 2011-05-31 11:59 -0400

#6733 — Re: scope of function parameters (take two)

FromTerry Reedy <tjreedy@udel.edu>
Date2011-05-31 11:59 -0400
SubjectRe: scope of function parameters (take two)
Message-ID<mailman.2317.1306857576.9059.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web