Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'granted,': 0.07; 'suddenly': 0.07; 'arguments': 0.09; 'read- only': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'language,': 0.12; 'changes': 0.15; '###': 0.16; '>on': 0.16; '>to': 0.16; 'failure.': 0.16; 'later)': 0.16; 'literals': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'scientist': 0.16; 'so!': 0.16; 'threw': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'passing': 0.19; 'aug': 0.22; 'print': 0.22; 'creating': 0.23; 'passes': 0.24; 'tend': 0.24; 'url:home': 0.24; 'header:X-Complaints-To:1': 0.27; '+0100,': 0.31; 'away.': 0.31; 'constant': 0.31; "d'aprano": 0.31; 'directly,': 0.31; 'prints': 0.31; 'sep': 0.31; 'steven': 0.31; 'older': 0.33; 'common': 0.35; 'but': 0.35; 'skip:> 10': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'received:76': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'most': 0.60; 'new': 0.61; 'such': 0.63; 'happen': 0.63; 'more': 0.64; 'effectively': 0.66; 'natural': 0.68; '(still': 0.84; 'pools': 0.84; 'promptly': 0.84; 'tended': 0.84; 'subject:skip:E 10': 0.95; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Encapsulation unpythonic? Date: Tue, 03 Sep 2013 22:41:13 -0400 Organization: IISS Elusive Unicorn References: <8255dfbd-a2a1-4ab7-b900-ee19faa459f2@googlegroups.com> <8c7c4854-70e1-46e7-a3ff-a3206c4c5c27@googlegroups.com> <5221567b$0$6599$c3e8da3$5496439d@news.astraweb.com> <5221d7ab$0$6599$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-110-181.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378262483 news.xs4all.nl 15883 [2001:888:2000:d::a6]:38512 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53591 On Tue, 03 Sep 2013 00:29:42 +0100, "Rhodri James" declaimed the following: >On Sat, 31 Aug 2013 12:46:52 +0100, Steven D'Aprano > wrote: > >> # THIS DOES NOT HAPPEN IN PYTHON >> # or any other language, as far as I am aware >> x = 23 >> y = x # y now has the value 23 >> x = 42 # change the value of the object ### NOT SO! ### >> print y >> => prints 42 > >Not directly, but FORTRAN did (does?) allow you to achieve this >oh-so-undesirable result indirectly. > >FORTRAN passes arguments to functions and procedures by reference. That >includes passing constants, which effectively get put into hidden >variables and passed across. Changes to the "constant" parameters in the >function can happen just as with any pass-by-reference, which would be >fine if you promptly threw the constant away. Unfortunately smart >compilers used to (still do?) keep pools of these common constant >"variables" around rather than creating new ones all the time, so changes >to "constants" persisted. Many's the poor natural scientist who was >perplexed to find that 0 suddenly had the value 1! Granted, this tended to be with older implementations. Most more modern (F77 and later) tend to allocate such literals in a read-only block of memory, so attempts to change them now cause a significant program failure. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/