Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6733
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: scope of function parameters (take two) |
| Date | 2011-05-31 11:59 -0400 |
| References | <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <F4EAD1ED-563D-4D6E-A50C-68308A9F26B7@mcgill.ca> <201105310713.24842.wolfgang@rohdewald.de> <D6671B7A-C8B1-4235-A50F-31D9F2AD7DD7@mcgill.ca> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2317.1306857576.9059.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: scope of function parameters (take two) Terry Reedy <tjreedy@udel.edu> - 2011-05-31 11:59 -0400
csiph-web