Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'element': 0.07; 'error:': 0.07; 'integers': 0.09; 'thats': 0.09; 'violates': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'assume': 0.14; '[5]': 0.16; 'declaration': 0.16; 'extension,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integers;': 0.16; 'programmer,': 0.16; 'subject:programming': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'error': 0.23; 'specify': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'restrict': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; '(since': 0.31; 'languages': 0.32; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'error.': 0.37; 'positive': 0.37; 'application': 0.37; 'list': 0.37; 'skip:[ 10': 0.38; 'does': 0.39; 'how': 0.40; 'above,': 0.60; 'dangerous': 0.60; 'expression': 0.60; 'term': 0.63; 'such': 0.63; 'different': 0.65; 'worth': 0.66; 'mar': 0.68; 'anything.': 0.68; 'to,': 0.72; 'that),': 0.91; 'to:none': 0.92; '***': 0.95 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=YuoeUjaqlVjvm+2fPV9RbrK+bOvmEf+V2w17WPNLP3Y=; b=d10vHNTgTJtd2N3tyy6tt9i4eYAZIA5wAa1fCZkplyXpMVPYP14n0hGfsDDSX401NA VQKjv9nOnhgh4ZNt2GyfGa/E4REDhL2umSQ36rTZbbdWDRDqxn6cs/O/ryqD/qhuIE8y 1Ry2scqclwdBmrhqNL74B8lFGnjhpfpV8cOjxIE+oDEAUxOir630zk5Llu7sD5wicmpP G0INBkauOGwTAw8q4cA6QJ5pSuHy0Yz7aAF2S6B1NNXncM0MaPKz0iTf346HlUmN77hP pGw+EQB4fDk0B4ExvH4cPajPq91/J/rbp9A5HPo14cpFVwjQLDje7K32K48pwCUdKTAP qzAw== MIME-Version: 1.0 X-Received: by 10.68.197.36 with SMTP id ir4mr19871566pbc.46.1393855217181; Mon, 03 Mar 2014 06:00:17 -0800 (PST) In-Reply-To: <3b54a279-03a1-4a81-a428-ecad6eb16036@googlegroups.com> References: <4c7dbc57-eef9-4582-aecd-aac13a39b45f@googlegroups.com> <3b54a279-03a1-4a81-a428-ecad6eb16036@googlegroups.com> Date: Tue, 4 Mar 2014 01:00:17 +1100 Subject: Re: Functional programming 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393855219 news.xs4all.nl 2944 [2001:888:2000:d::a6]:58418 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67546 On Tue, Mar 4, 2014 at 12:48 AM, Rustom Mody wrote: > ? [1,2] + [[3,4],[5]] > ERROR: Type error in application > *** expression : [1,2] + [[3,4],[5]] > *** term : [1,2] > *** type : [Int] > *** does not match : [[Int]] > > IOW [1,2,[3,4],[5]] > is a type-wise ill-formed expression just as in python > [[1,2]) > is syntax-wise ill-formed > > Is it worth having such a restriction? > Thats a different argument... How do you know that [1,2] is a list that must contain nothing but integers? By extension, it's also a list that must contain positive integers less than three, so adding [5] violates that. And [] is a list that must contain nothing, ergo it can't be added to, although (since it contains nothing) it can be added to anything. Some languages do let you specify element types (Pike has an "array" type that can hold anything, or you can say "array(int)" to restrict it to integers; you could also say "array(int(1..2))" to specify what I said above, if you actually intend that), but without a declaration from the programmer, it's dangerous to assume there's an error. ChrisA