Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(at': 0.04; 'causing': 0.04; 'from:addr:yahoo.co.uk': 0.04; 'python)': 0.05; 'lawrence': 0.09; 'methods,': 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; 'def': 0.12; 'language.': 0.14; '*always*': 0.16; 'chris,': 0.16; 'corresponds': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sorts': 0.16; 'subject:generator': 0.16; '(0)': 0.16; 'language': 0.16; 'wrote:': 0.18; 'value.': 0.19; '(the': 0.22; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'example.': 0.24; 'specify': 0.24; '15,': 0.26; 'least': 0.26; 'subject:/': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; '>>>>': 0.31; 'void': 0.31; 'something': 0.35; 'usual': 0.35; 'but': 0.35; '14,': 0.36; 'functions.': 0.36; 'useful': 0.36; 'writes': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'march': 0.61; 'effective': 0.61; 'such': 0.63; 'our': 0.64; 'more': 0.64; 'taking': 0.65; 'charset:windows-1252': 0.65; 'due': 0.66; 'between': 0.67; 'mar': 0.68; 'respect': 0.70; '2015': 0.84; 'concept.': 0.84; 'distinguish': 0.84; 'returns.': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: generator/coroutine terminology Date: Sat, 14 Mar 2015 16:56:53 +0000 References: <5501be8b$0$13006$c3e8da3$5496439d@news.astraweb.com> <87twxqqewm.fsf@elektro.pacujo.net> <4eec1709-dd11-4891-bfcc-60b27bb00ee3@googlegroups.com> <550259bf$0$12975$c3e8da3$5496439d@news.astraweb.com> <00d9152a-f391-4c64-b2bd-52bdec2a6b67@googlegroups.com> <8761a5s0he.fsf@elektro.pacujo.net> <5503cf5f$0$12985$c3e8da3$5496439d@news.astraweb.com> <83d579c1-ab61-4a3d-a834-e65d28eace8a@googlegroups.com> <976313df-00f6-4845-a774-e5902b0fb2ce@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-78-147-178-18.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: <976313df-00f6-4845-a774-e5902b0fb2ce@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1426352231 news.xs4all.nl 2864 [2001:888:2000:d::a6]:52715 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87430 On 14/03/2015 16:33, Rustom Mody wrote: > On Saturday, March 14, 2015 at 9:45:10 PM UTC+5:30, Chris Angelico wrote: >> On Sun, Mar 15, 2015 at 2:59 AM, Rustom Mody wrote: >>> Causing all sorts of unnecessary confusions: >>> An int-function returns int and a char*-functions returns char*. >>> Does a void-function return void?? >>> No a void function doesn't return anything! >>> Ah So a void function does a longjmp? >>> >>> All of which is to say that in retrospect we need (at least in imperative programming) procedures and functions. >>> >>> Best if the language supports them >> >> Python has a broad concept of "functions/methods that return something >> interesting" and "functions/methods that always return None". (The >> distinction often corresponds to non-mutator and mutator methods, but >> that's just convention.) > > With due respect Chris, you are confused: > > Sure any effective *pythonista* (who writes useful python) will have this concept. > > Python (as against pythonistas) has no such conceptš as "function that ALWAYS > returns None" > > Consider this foo > >>>> def foo(x): > ... if x>0: return x-1 > ... >>>> foo(3) > 2 >>>> foo(-1) >>>> > > As best as I can see python makes no distinction between such a foo and > the more usual function/methods that have no returns. > You can I can talk about these and distinguish them > Python has no clue about it. > Python *ALWAYS* returns None for any path through a function that doesn't specify a return value. Taking your example. >>> def foo(x): ... if x>0: return x-1 ... >>> import dis >>> dis.dis(foo) 2 0 LOAD_FAST 0 (x) 3 LOAD_CONST 1 (0) 6 COMPARE_OP 4 (>) 9 POP_JUMP_IF_FALSE 20 12 LOAD_FAST 0 (x) 15 LOAD_CONST 2 (1) 18 BINARY_SUBTRACT 19 RETURN_VALUE >> 20 LOAD_CONST 0 (None) 23 RETURN_VALUE -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence