Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #67557

Re: Functional programming

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'programmer': 0.03; 'yet.': 0.04; 'explicit': 0.07; 'string': 0.09; 'restriction': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language.': 0.14; '1:08': 0.16; 'declaration': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'overlaps': 0.16; 'programmer,': 0.16; 'resolved?': 0.16; 'subject:programming': 0.16; "type's": 0.16; 'elements': 0.16; 'wrote:': 0.18; "python's": 0.19; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'of.': 0.24; 'earlier': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'then.': 0.30; 'message- id:@mail.gmail.com': 0.30; 'int,': 0.31; 'cases': 0.33; 'could': 0.34; 'problem.': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'in.': 0.36; 'list': 0.37; 'skip:[ 10': 0.38; 'sure': 0.39; 'how': 0.40; 'tell': 0.60; 'hope': 0.61; 'complete': 0.62; 'kind': 0.63; 'more': 0.64; 'mar': 0.68; 'yes': 0.68; 'difficulty': 0.68; 'union': 0.69; 'therefore': 0.72; 'picture.': 0.84; 'pike': 0.84; 'tricky': 0.84; 'to:none': 0.92; 'fight': 0.97
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=Azp1Eopnac9/lT8U5/uKzojjh0qiuvBLRW2BvCu44oU=; b=wyQBEewWG4saqzsCDdV7CCduE2V0BfBU3eFmEpHbA3/q9Z0PVKslZRiQbxXnkX3n95 UrJw9q7nUxzrRY3/8xQ+n6dWZ4uZywOmFiQxtc5ldIRYtexDBz03TaY7L+V1ec0kVf9Z n4iIy//Jwp/hDpy0+gzMdRq5KkBYc6rTDMIMnIZX+bS1YdCkqOzMDK/7mdAFHWynQN12 /g5sUPeyTrjlBg9jGAEml/j7ieGy5UqC4FZvglR1ycepgmGpn86iBEdbTdssIVDSewBS UY5ak/BMbHKUwT6tVsYDFZJUgQ+uxiJnbhwmVgtZ9htwugyQga8esC22RwoKks1wSiyb fthA==
MIME-Version 1.0
X-Received by 10.68.200.74 with SMTP id jq10mr2507772pbc.169.1393858907754; Mon, 03 Mar 2014 07:01:47 -0800 (PST)
In-Reply-To <0129a5b9-b85f-4ad5-b5e2-bfb2a48041d5@googlegroups.com>
References <B512F079-4F01-4865-BEF3-07DF94F21832@gmail.com> <mailman.7612.1393810048.18130.python-list@python.org> <4c7dbc57-eef9-4582-aecd-aac13a39b45f@googlegroups.com> <mailman.7633.1393849247.18130.python-list@python.org> <3b54a279-03a1-4a81-a428-ecad6eb16036@googlegroups.com> <mailman.7641.1393855219.18130.python-list@python.org> <216bb5f4-32c4-4f86-a9f4-1b0dd37a2a81@googlegroups.com> <mailman.7644.1393856584.18130.python-list@python.org> <0129a5b9-b85f-4ad5-b5e2-bfb2a48041d5@googlegroups.com>
Date Tue, 4 Mar 2014 02:01:47 +1100
Subject Re: Functional programming
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7647.1393858917.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393858917 news.xs4all.nl 2895 [2001:888:2000:d::a6]:34708
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67557

Show key headers only | View raw


On Tue, Mar 4, 2014 at 1:38 AM, Rustom Mody <rustompmody@gmail.com> wrote:
> If you want the (semantic) equivalent of python's [1,2,'foo']
> you need to make an explicit union Int and String and its that
> *single* union type's elements that must go in.
>
> In all cases its always a single type. And so
> sum([1,2,[3])

Okay. That's how the declaration goes, then. So how do you tell it
that 1 isn't an Int, it's a member of the union of Int and String? How
do you create a list which has [Int_String(1), Int_String(2)] and is
therefore allowed to be added to [Int_String('foo')] ? Can you do that
with literals?

This is why it's tricky to put rules in based on type inference. The
programmer's intent isn't in the picture. If Python ever acquires that
kind of restriction ("here's a list that can contain only this type /
these types of object"), I would hope that it's left up to the
programmer, not the compiler, to stipulate. That's how it is with Pike
(if you just say "array", it can take anything), and that's the only
way to be sure the programmer doesn't have to fight the language.

You said earlier

>> On Tue, Mar 4, 2014 at 1:08 AM, Rustom Mody wrote:
>> > If 'integer-less-than-3' were a type then yes there would be this
>> > problem. More generally, if types could overlap then automatic
>> > type-inference is impossible

The type "Int" overlaps with the type "Union of Int and String". How
is that resolved? Type inference ignores unions? That's the only way I
can think of. Hence the original difficulty of type-inferring on a
list that isn't complete yet.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Functional programming Ned Batchelder <ned@nedbatchelder.com> - 2014-03-02 20:27 -0500
  Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 03:45 -0800
    Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-03 23:20 +1100
      Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 05:48 -0800
        Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 05:51 -0800
        Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-04 01:00 +1100
          Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 06:08 -0800
            Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-04 01:23 +1100
              Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 06:38 -0800
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-04 02:01 +1100
                Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 07:28 -0800
                Re: Functional programming Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-03 17:27 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-04 05:37 +1100
                Re: Functional programming Steven D'Aprano <steve@pearwood.info> - 2014-03-04 05:35 +0000
                Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 21:59 -0800
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-04 17:04 +1100
                Re: Functional programming Rustom Mody <rustompmody@gmail.com> - 2014-03-03 22:20 -0800
                Re: Functional programming Steven D'Aprano <steve@pearwood.info> - 2014-03-04 08:56 +0000
                Re: Functional programming Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2014-03-04 11:56 +0100
                Re: Functional programming Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 11:47 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 00:01 +1100
                OT Sine Rule [was Re: Functional programming] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 14:25 +0000
                Re: OT Sine Rule [was Re: Functional programming] Tim Chase <python.list@tim.thechases.com> - 2014-03-04 08:37 -0600
                Re: OT Sine Rule [was Re: Functional programming] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-04 14:42 +0000
                Re: OT Sine Rule [was Re: Functional programming] Chris Angelico <rosuav@gmail.com> - 2014-03-05 02:06 +1100
                Re: OT Sine Rule [was Re: Functional programming] Tim Chase <python.list@tim.thechases.com> - 2014-03-04 09:21 -0600
                Re: Functional programming Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2014-03-05 09:59 +0100
                Re: Functional programming Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 21:49 +0200
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 07:01 +1100
                Re: Functional programming Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 22:50 +0200
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 08:06 +1100
                Re: Functional programming Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 23:21 +0200
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 08:26 +1100
                Re: Functional programming Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 23:43 +0200
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 08:52 +1100
                Re: Functional programming Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-05 12:57 +1300
                Re: Functional programming Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 02:11 +0200
                Re: Functional programming "BartC" <bc@freeuk.com> - 2014-03-04 13:30 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 00:47 +1100
                Re: Functional programming Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-04 14:05 +0000
                Re: Functional programming Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 14:55 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 02:13 +1100
                Re: Functional programming MRAB <python@mrabarnett.plus.com> - 2014-03-04 17:07 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 01:17 +1100
                Re: Functional programming Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 15:18 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 02:28 +1100
                Re: Functional programming Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 15:45 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 03:04 +1100
                Re: Functional programming Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2014-03-05 10:09 +0100
                Re: Functional programming "BartC" <bc@freeuk.com> - 2014-03-05 11:28 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-05 23:04 +1100
                Re: Functional programming Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 14:11 +0200
                Re: Functional programming Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-04 11:06 +1300
                Re: Functional programming Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 09:31 +1100
                Re: Functional programming Grant Edwards <invalid@invalid.invalid> - 2014-03-04 14:59 +0000
                Re: Functional programming Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 15:22 +0000
                Re: Functional programming Chris Angelico <rosuav@gmail.com> - 2014-03-04 09:42 +1100
                Re: Functional programming Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 10:52 +1100
                Re: Functional programming "BartC" <bc@freeuk.com> - 2014-03-04 09:41 +0000
            Re: Functional programming 88888 Dihedral <dihedral88888@gmail.com> - 2014-03-03 16:35 -0800

csiph-web