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!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'interfaces': 0.04; 'suppose': 0.07; 'compile-time': 0.09; 'integers': 0.09; 'structure,': 0.09; 'subject: [': 0.09; 'language,': 0.12; 'wrote': 0.14; '(modulo': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'kern': 0.16; 'sorts': 0.16; 'subject:"]': 0.16; 'language': 0.16; 'wrote:': 0.18; 'implementing': 0.19; 'input': 0.22; 'subject:problem': 0.24; 'java': 0.24; 'regardless': 0.24; 'somewhere': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'robert': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'class': 0.32; 'this.': 0.32; 'stuff': 0.32; 'ago': 0.33; 'checking': 0.33; 'fri,': 0.33; 'could': 0.34; 'subject:with': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'done': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'easily': 0.37; 'to:addr:python-list': 0.38; 'anything': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'providing': 0.61; 'subject:The': 0.64; 'square': 0.74; 'viable': 0.84; '2013': 0.98 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:to :content-type; bh=3SI5lAcYeWE07AhRtKYCjCfrgnhn3eOsy/VvxwHnf80=; b=a/6pfEzmkx9yidOobr171j72ozQTmif1gAhqueGTMMMZcJYZx/cXRqGCChhkK1frUI 50EB6KehtvH0LzIGW7FSbjzasrhPDUDADl2C9eAKAug9XXHcrTtJ0nrF8LAQcE1VMpiU k5/DptWXcaGsWIqQb6eSss3pH+2Bw1RAWrBx9rsRkYVPnoPdG9i053SQoDSc7DpQNj/8 fpKXiqGJl6vjBUX5hmAAKUEnqsMV+vNFUXQZK86a7lFuHz03pg5FhVl7ew/IqwXan0hw CiEVG+QHKUWT5MhdmHtnIFabGOOiuWVP/peY/R9bDzxoO27KgZxBaQTKjl9ovvJLu9zc Xv1Q== MIME-Version: 1.0 X-Received: by 10.220.109.66 with SMTP id i2mr22221422vcp.51.1370533293799; Thu, 06 Jun 2013 08:41:33 -0700 (PDT) In-Reply-To: References: <687dea63-84da-4c45-9366-cb5a10665d1f@googlegroups.com> <51ab95d5$0$29966$c3e8da3$5496439d@news.astraweb.com> <51ad7daf$0$11118$c3e8da3@news.astraweb.com> <31ca14e1-973d-44e6-886c-011a55755d76@googlegroups.com> <96cd7a31-40ce-4e51-9489-446b7f002a0e@googlegroups.com> <51afec46$0$29966$c3e8da3$5496439d@news.astraweb.com> <51b0565d$0$11118$c3e8da3@news.astraweb.com> Date: Fri, 7 Jun 2013 01:41:33 +1000 Subject: Re: Bools and explicitness [was Re: PyWart: The problem with "print"] From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370533633 news.xs4all.nl 15935 [2001:888:2000:d::a6]:56742 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47235 On Fri, Jun 7, 2013 at 1:35 AM, Robert Kern wrote: > On 2013-06-06 10:45, Chris Angelico wrote: > >> For the "accept any object that has a next() method" sorts of rules, I >> don't know of any really viable system that does that usefully. The >> concept of implementing interfaces in Java comes close, but the class >> author has to declare that it's implementing some named interface. In >> theory there could be something that deduces the validity from the >> given structure, but I'm not aware of any language that does this. But >> it would let you do stuff like this (prototyped in Python): > > > As Serhiy notes, Go does this, almost exactly as you wrote it (modulo > syntax). > > http://golang.org/doc/effective_go.html#interfaces_and_types Thanks (and thanks for actually providing a link). Many years ago I came to the conclusion that anything I could conceive in language design has already been done somewhere :) Anyway, regardless of your language, there's always some criteria that can't be coded. Suppose the valid input for a function were "integers whose square roots are integers but whose cube roots are not". You won't easily get compile-time checking of that. ChrisA