Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Useless expressions [was Re: Undefined behaviour in C] Date: Mon, 28 Mar 2016 14:29:41 +1100 Lines: 36 Message-ID: References: <56f42d9f$0$1618$c3e8da3$5496439d@news.astraweb.com> <56f55e2e$0$1619$c3e8da3$5496439d@news.astraweb.com> <87wpoq1omm.fsf@elektro.pacujo.net> <56f5f81d$0$1585$c3e8da3$5496439d@news.astraweb.com> <87io0a6j1w.fsf@nightsong.com> <56f67ee3$0$1583$c3e8da3$5496439d@news.astraweb.com> <87poug5t0c.fsf@nightsong.com> <56f887c1$0$1598$c3e8da3$5496439d@news.astraweb.com> <20160327215911.755881f5@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de IY1m2lldm6LyjHnS+2z2dwKAx6YfuxnZIeVSkkl1Jesg== 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; 'operator': 0.03; 'received:209.85.223': 0.03; 'compiler': 0.05; 'discard': 0.05; 'cc:addr:python-list': 0.09; 'thread': 0.10; 'useful,': 0.13; 'value.': 0.15; '12:38,': 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'imo,': 0.16; 'personally,': 0.16; 'pipes': 0.16; 'rather,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:expressions': 0.16; 'things"': 0.16; 'wrote:': 0.16; 'result,': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'pipe': 0.22; 'leave': 0.23; 'tim': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'sort': 0.25; 'chris': 0.26; 'message- id:@mail.gmail.com': 0.27; 'said,': 0.27; 'bad.': 0.29; 'chase': 0.29; 'concern': 0.29; 'subject: [': 0.29; "i'm": 0.30; 'that.': 0.30; 'code': 0.30; "i'd": 0.31; "can't": 0.32; 'aside': 0.32; 'steven': 0.33; 'though.': 0.33; 'that,': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'c++': 0.35; 'generic': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'things': 0.38; 'received:209': 0.38; 'several': 0.38; 'does': 0.39; 'rather': 0.39; 'where': 0.40; 'still': 0.40; 'more': 0.63; 'different': 0.63; 'times': 0.63; 'mar': 0.65; 'talking': 0.67; 'useful.': 0.72; 'chrisa': 0.84; 'designed,': 0.84; 'done:': 0.84; 'dsl': 0.84; 'syntax;': 0.84; 'to:none': 0.91; 'drops': 0.91; 'poorly': 0.93 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; bh=WPPR0GQFtqOX0kENQbQNbawoudiw0btFeGoIyHg9Jk4=; b=NPKIwgAYekMT8aHI0OEGI9bZopYxHAoTvNDXf7LW5rI9buv+eOddEtsFoYSaGyygb4 gosi7NmLVTzwd6j00mkIgpNUvpfR3y3il+fmV+IQLJzFUxPL/hcnjBR18oWFgJ/Xvzei GdtgvZ8i617+gCSD5DvZ92/4sU5ReVpVe4seNe5x+kEapRfuKRugsICUajrUiNrhiJmW LZ1g1GKqEqWeocZKqRRiHkx/hbJ7g8NeLwHeGdbh9jfso8NWsqerFRmq3LF3KEXNyUT1 9Xi0h0FoAIKolvPLLq+dksO1oQY/FlCMCVwM6SpFIdAhLpgV7U5haLMwhMHUEHjCGnvY Ik8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=WPPR0GQFtqOX0kENQbQNbawoudiw0btFeGoIyHg9Jk4=; b=c5iRezWs1P4khobjIB6sIcWNZ8gTlqGUxYnuk76/2QA9ec32rHVI3rv4NPbeblGgnH Ot8+AXEYVu97py09PkFAeMKt3p4n7ffO59Jj5Mri5yVlJjRCNFSsLeTI4quPB0gucqDT uQVTWp4JjgQIKEAtFudjNuxiCayFJrQHFGLPPJSn7ZZ0zXjcMs588exbDkRSvZPgU61R Y52pO/ZrFZRvd96s/VCnia6w1OofNicAaDcTeuY7u6xr1DnD16mWsn4/3qgY5p7Xr4C5 EWXoQTB1sQVVbjnvjWJJb5zpYtu7REZQVArAU/ruLaup2P873RnnuDn4rej+/NDEbuiq nS/A== X-Gm-Message-State: AD7BkJIq4yrGA7alKSkyj76TqaLah+ITicxKaNhW4wZueauVwlbozr1IGd8AqIOXX7nUHMw/IDBKq7dpxOJboQ== X-Received: by 10.107.169.105 with SMTP id s102mr22120720ioe.19.1459135782038; Sun, 27 Mar 2016 20:29:42 -0700 (PDT) In-Reply-To: <20160327215911.755881f5@bigbox.christie.dr> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105893 On Mon, Mar 28, 2016 at 1:59 PM, Tim Chase wrote: > On 2016-03-28 12:38, Chris Angelico wrote: >> I would still look askance at code that adds two things and drops >> the result, though. The compiler can't discard it, but if a linter >> complains, I'd support that. A DSL that requires you to do this is, >> imo, poorly designed. > > Is it only the "*add* two things" or are you decrying any generic > operator that gets evaluated and then drops the result? > > Steven recently opened a thread ["Bash-like pipes in Python"] where > this exact sort of thing would be done: > > get_values() | filter("smith") | sort("income") | send_to_printer() > > Several different solutions were posited with varying degrees of > conciseness-vs-pythonicity-vs-pipe'ness. I was talking about any operator that, for built-in types, does no mutation and has no effect aside from its return value. So yes, the use of the pipe is a perfect counter-example - or rather, proof that my concern is a code smell rather than fundamentally bad. C++ started it with the iostream << and >> overloads; personally, I think that's more cute than useful, but there are times when it can be extremely useful. So I revise my stance: A DSL that requires you to do this *may be* poorly designed, and needs a very solid justification. > That said, I'm in the "let the compiler accept valid syntax; leave it > to the linter" camp. Yeah definitely. ChrisA