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: 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: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=1.168.129.131; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: 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 Terry Reedy=E6=96=BC 2012=E5=B9=B41=E6=9C=885=E6=97=A5=E6=98=9F=E6=9C=9F=E5= =9B=9BUTC+8=E4=B8=8A=E5=8D=884=E6=99=8222=E5=88=8603=E7=A7=92=E5=AF=AB=E9= =81=93=EF=BC=9A > On 1/4/2012 1:37 AM, Terry Reedy wrote: > > On 1/3/2012 8:04 PM, Devin Jeanpierre wrote: >=20 > >> [ An example of a simple dependently typed program: > >> http://codepad.org/eLr7lLJd ] > > > > Just got it after a minute delay. >=20 > A followup now that I have read it. Removing the 40 line comment, the=20 > function itself is >=20 > fun getitem{n,m:nat}(arr : array(int, n) , > length : int(n), index : int m) : int =3D > if index < length then > arr[index] > else > ~1 (* -1, error *) >=20 > where n,m are compiler variables used to define the dependent=20 > (paramaterized) types array(int,n) and int(n)/ The double use of n means= =20 > that the compiler checks that length n of the array equals the length=20 > passed. >=20 > My response: in Python, there is no need to pass concrete collection=20 > sizes because they are packaged with the collection at runtime as an=20 > attribute. So: >=20 > 1) In Python, there is no need for such checking. In addition, the=20 > for-loop construct, 'for item in iterable:', removes the possibility of= =20 > indexing errors. >=20 > 2) Python classes are, in a sense, or in effect, runtime dependent=20 > types. While the formal implementation type of a 'list' is just 'list',= =20 > the effective computation type is 'mutable sequence of length n'. The=20 > type of an iterator is 'read-only sequence of indefinite length'. I find= =20 > 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=20 without declaring a new class from a class written by others. Thus this can lead to a decoupled design of software among many contributo= rs in an elegant way. =20 I prefer a factorized decoupled blocks of modules to be completed=20 by several programmers to build a package. =20 >=20 > --=20 > Terry Jan Reed