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


Groups > comp.lang.python > #18648

Re: python philosophical question - strong vs duck typing

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <dihedral88888@googlemail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'python.': 0.04; 'compiler': 0.07; 'removes': 0.07; 'terry': 0.07; 'typed': 0.07; 'python': 0.08; 'attribute.': 0.09; 'comment,': 0.09; 'decorator': 0.09; 'reply-to:addr:comp.lang.python': 0.09; 'runtime': 0.09; 'to:addr:comp.lang.python': 0.09; 'subject:python': 0.10; 'am,': 0.12; 'package.': 0.12; '8bit%:72': 0.16; 'computation': 0.16; 'declaring': 0.16; 'iterator': 0.16; 'passed.': 0.16; 'reedy': 0.16; 'cc:addr:python-list': 0.16; 'subject:question': 0.17; 'wrote:': 0.18; 'int': 0.18; 'jan': 0.19; 'cc:no real name:2**0': 0.20; 'written': 0.20; 'header:In- Reply-To:1': 0.22; 'thus': 0.23; 'indexing': 0.23; 'cc:2**0': 0.24; 'index': 0.24; 'classes': 0.26; 'function': 0.27; 'received:209.85.220': 0.27; 'pass': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.29; 'pm,': 0.29; 'class': 0.29; 'example': 0.29; 'array': 0.30; '-1,': 0.30; 'checking.': 0.30; 'followup': 0.30; 'indexed': 0.30; 'types.': 0.30; 'dependent': 0.32; 'programmers': 0.32; 'header:User-Agent:1': 0.33; 'there': 0.33; 'object': 0.33; 'it.': 0.34; 'from:addr:googlemail.com': 0.34; 'elegant': 0.34; 'sense,': 0.34; 'modules': 0.35; 'addition,': 0.36; 'checks': 0.37; 'sequence': 0.37; 'subject:skip:p 10': 0.37; 'variables': 0.37; 'received:google.com': 0.37; 'several': 0.38; 'received:209.85': 0.38; 'url:org': 0.39; 'else': 0.39; 'define': 0.39; 'received:209': 0.40; 'type': 0.61; 'types': 0.61; 'design': 0.61; 'effective': 0.61; 'double': 0.61; 'program:': 0.67; 'collection': 0.69; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:googlegroups.com': 0.74; 'contributors': 0.84; 'packaged': 0.84; 'so:': 0.84; 'delay.': 0.91; 'skip:2 50': 0.91
Newsgroups comp.lang.python
Date Sat, 7 Jan 2012 07:43:56 -0800 (PST)
In-Reply-To <mailman.4424.1325708545.27778.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=1.168.129.131; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw
References <CAOFf2a0dG1tR1-2sJnqCCGqVXocqvzGScGeDJXeXwKdfdvuT-Q@mail.gmail.com> <jdvovs$iri$1@dough.gmane.org> <CABicbJ+jQ7e7FD+2waKVS5F5-WwQCykTUh=h4Y=mE_0Pjep_2g@mail.gmail.com> <jdvsor$dha$1@dough.gmane.org> <CABicbJKO_2iN-B4+B8O81qEFqeVQ85s_CUa70U0s9JWnrPTYgQ@mail.gmail.com> <je0s2j$2k6$1@dough.gmane.org> <mailman.4424.1325708545.27778.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
MIME-Version 1.0
Subject Re: python philosophical question - strong vs duck typing
From 88888 Dihedral <dihedral88888@googlemail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To comp.lang.python@googlegroups.com
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.4514.1325951044.27778.python-list@python.org> (permalink)
Lines 60
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325951044 news.xs4all.nl 6927 [2001:888:2000:d::a6]:56350
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18648

Show key headers only | View raw


Terry Reedy於 2012年1月5日星期四UTC+8上午4時22分03秒寫道:
> On 1/4/2012 1:37 AM, Terry Reedy wrote:
> > On 1/3/2012 8:04 PM, Devin Jeanpierre wrote:
> 
> >> [ An example of a simple dependently typed program:
> >> http://codepad.org/eLr7lLJd ]
> >
> > Just got it after a minute delay.
> 
> A followup now that I have read it. Removing the 40 line comment, the 
> function itself is
> 
> fun getitem{n,m:nat}(arr : array(int, n) ,
>   length : int(n), index : int m) : int =
>      if index < length then
>          arr[index]
>      else
>          ~1 (* -1, error *)
> 
> where n,m are compiler variables used to define the dependent 
> (paramaterized) types array(int,n) and int(n)/ The double use of n means 
> that the compiler checks that length n of the array equals the length 
> passed.
> 
> My response: in Python, there is no need to pass concrete collection 
> sizes because they are packaged with the collection at runtime as an 
> attribute. So:
> 
> 1) In Python, there is no need for such checking. In addition, the 
> for-loop construct, 'for item in iterable:', removes the possibility of 
> indexing errors.
> 
> 2) Python classes are, in a sense, or in effect, runtime dependent 
> types. While the formal implementation type of a 'list' is just 'list', 
> the effective computation type is 'mutable sequence of length n'. The 
> type of an iterator is 'read-only sequence of indefinite length'. I find 
> this an interesting way to look at Python.

Also it is easy to turn an indexed object to be an iterator by a
function decorator that returns a generator in the object level 
without declaring a new class from a class written by others.

Thus this can lead to  a decoupled design of software among many contributors
in an elegant way.  

I prefer a factorized decoupled blocks of modules to be completed 
by several programmers to build a package.  


> 
> -- 
> Terry Jan Reed

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


Thread

Re: python philosophical question - strong vs duck typing Terry Reedy <tjreedy@udel.edu> - 2012-01-04 15:22 -0500
  Re: python philosophical question - strong vs duck typing 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-07 07:43 -0800
  Re: python philosophical question - strong vs duck typing 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-07 07:43 -0800

csiph-web