Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'assignment': 0.07; 'imply': 0.09; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'stored': 0.12; 'wrote': 0.14; 'literals': 0.16; 'mutable': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:parameters': 0.16; 'subroutine': 0.16; 'language': 0.16; 'passing': 0.19; 'meant': 0.20; 'passes': 0.24; 'header:X -Complaints-To:1': 0.27; 'code': 0.31; 'that.': 0.31; 'types.': 0.31; 'with,': 0.31; 'fri,': 0.33; "can't": 0.35; 'late': 0.35; 'one,': 0.35; 'problems': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'even': 0.60; 'future': 0.60; 'course.': 0.60; 'first': 0.61; 'address': 0.63; 'confirm': 0.64; 'production': 0.68; 'default': 0.69; 'hand.': 0.84; 'imagine': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Default mutable parameters in functions Date: Fri, 4 Apr 2014 22:21:01 -0400 (EDT) Organization: news.gmane.org References: <1396620025.10391.102762569.6DD0D52A@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dpc6744192021.direcpc.com X-Newsreader: PiaoHong.NewsGroup.Client.VIP:1.52 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396664147 news.xs4all.nl 2852 [2001:888:2000:d::a6]:35144 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69697 Dennis Lee Bieber Wrote in message: > On Fri, 04 Apr 2014 10:00:25 -0400, random832@fastmail.us declaimed the > following: > >> >>I can't imagine a language that would work that way. For one, it would >>also imply that passing a value would change the default for future >>calls even for non-mutable types. > > Some early FORTRAN compilers purportedly had problems with, for > example: > > X = 1 > call mutant(1) > Y = 1 > > where > > subroutine mutant(y) > > y = y + 1 > return > > meant that Y now held the value of 2 -- that is, literals were stored in > mutable memory, and since FORTRAN passes by reference, the address of the > literal is passed, and the assignment changed the "constant". I can confirm that, first hand. In late 60's, CDC 6400, I deliberately wrote code to exploit that. Not for production of course. -- DaveA