Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'lines,': 0.07; 'difference,': 0.09; 'integers': 0.09; 'style.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'array.': 0.16; 'finite': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lisp': 0.16; 'precision.': 0.16; 'semantics': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'wed,': 0.18; 'example': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'certainly': 0.24; 'integer': 0.24; 'mathematical': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'equivalent': 0.26; 'header :In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'array': 0.29; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'lines': 0.31; "we're": 0.32; "can't": 0.35; 'something': 0.35; 'beyond': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'possible': 0.36; 'similar': 0.36; 'wrong': 0.37; 'list': 0.37; 'list.': 0.37; 'pm,': 0.38; 'anything': 0.39; 'expect': 0.39; 'though,': 0.39; 'how': 0.40; 'become': 0.64; 'more': 0.64; 'different': 0.65; 'size.': 0.65; 'between': 0.67; 'to,': 0.72; 'guaranteed': 0.75; '"it': 0.84; 'pike': 0.84; 'rexx,': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=5uGFANCPt9HEwcp5QUN3av2BH0JkEacgxri2/aASa0s=; b=Ar5fvfjFzs8JLBYdoF5kBrpCIOKB0qHPtY2XzHl67d/C8fy4VsqRrT8ap9SdBMDAmX 8CKYTwb0CBAItXl1wDd1TeL0zntG5vFwgoBB1Cnezo0DzxbNaZsc6tTvY+gI2q0Kurc2 H/ub3PYRoiQPllWwO19gxLpa5Ut8UXN2YB7GeYy7JZGEhQ5Pe9S0IA8G3jDTB7GeCTAz 2FMO7vjFdolia7VHrhUG/H6cTQ65cJI/jGCrbfYsltNxCH86KSVAChfJ6/CbUrx/R1oo 116gc+AjOjV46cZ5EgDsWwhRskmSJLcd80PcbQM+h6jtIDkx1bpm0rMGSjLGVsFrcSAs MajA== MIME-Version: 1.0 X-Received: by 10.220.105.4 with SMTP id r4mr9893509vco.27.1399430374353; Tue, 06 May 2014 19:39:34 -0700 (PDT) In-Reply-To: References: <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> <5368681D.8070602@islandtraining.com> Date: Wed, 7 May 2014 12:39:34 +1000 Subject: Re: Pass variable by reference From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 1399430382 news.xs4all.nl 2912 [2001:888:2000:d::a6]:47704 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71004 On Wed, May 7, 2014 at 12:18 PM, Rustom Mody wrote: > Wrong conclusion! > > These 3 lines look the same and amount to much the same in python and C. > > But as the example widens to something beyond 3 lines, the difference > will become more and more significant Python, C, REXX, BASIC, and pretty much anything else with a broadly imperative style. The thing is, though, the difference between one language's variable semantics and another's is similar to, as Ned said, the difference between one language's integer semantics and another's. What happens in C when you do this? x = 1 << 31; x += x; The only possible answer is "it depends", as you can't know how big an int is, but certainly it's of finite size. In Python, the equivalent is guaranteed to put 2**32 into x, because integers store arbitrary precision. That's a pretty important difference, yet we're happy to call both "integer". A Python list is very different from a LISP list. A Python array is very different from a Pike array. A Python function is very different from a mathematical function. Why do we object to the difference in "variable" but not the others? Yes, there are differences. That's why we have different languages; you can't do a minimalist transformation of source code and expect exactly identical semantics. But we start with familiar names that will give people some idea of what's going on. ChrisA