Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'example:': 0.03; 'syntax': 0.04; 'argument': 0.05; 'run-time': 0.05; 'subject:Python': 0.06; 'compiler': 0.07; 'bold': 0.09; 'main()': 0.09; 'sentence': 0.09; 'thereof.': 0.09; 'thus,': 0.09; 'type,': 0.09; 'def': 0.12; 'language.': 0.14; "(it's": 0.16; 'argument,': 0.16; 'constructs': 0.16; 'disallow': 0.16; 'error).': 0.16; 'foo()': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'get,': 0.16; 'itself,': 0.16; 'similarly,': 0.16; 'sub-class': 0.16; 'subclass': 0.16; 'subject:Java': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'all,': 0.19; 'trying': 0.19; 'seems': 0.21; '(the': 0.22; 'example': 0.22; 'programming': 0.22; 'oriented': 0.24; 'pointer': 0.24; 'fairly': 0.24; 'class.': 0.26; 'equivalent': 0.26; 'pass': 0.26; 'defined': 0.27; 'header:In- Reply-To:1': 0.27; 'on,': 0.29; 'resolution': 0.29; 'thus': 0.29; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; '(since': 0.31; '-0700,': 0.31; "d'aprano": 0.31; 'implicit': 0.31; 'steven': 0.31; 'struct': 0.31; 'work:': 0.31; 'class': 0.32; 'supposed': 0.32; 'another': 0.32; 'could': 0.34; 'subject: (': 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'c++': 0.36; 'method': 0.36; 'step': 0.37; 'being': 0.38; 'problems': 0.38; 'depends': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'does': 0.39; 'itself': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'even': 0.60; 'identify': 0.61; 'effective': 0.61; 'making': 0.63; 'real': 0.63; 'more': 0.64; 'here': 0.66; 'believe': 0.68; 'safe': 0.72; 'guaranteed': 0.75; '"spam"': 0.84; 'technique.': 0.84; 'cast': 0.91; 'mean.': 0.91; 'inheritance,': 0.93; '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=1NggtF0FVUQ/LW/oTbpAsDWEgnQshjZUh4CYFAY1H1w=; b=l/QFeR9C6tAtCuaQQlB7MNpLfpiJHFZzBWPweWsue/LrQeyadtXwDdwqLeJtdpPk8A QDjRW/GPaZSysXie04v2Sf6jU6dPZArSBDyc2R2b36mej39MtpYMhWp2Hyg/NNTRxgZX TD4IyvNgqTBgrnAodnhHRGcoSNYlgh7I+b7VP6qFpyRjEI5PKtRs7ckU/sPuh+Zv/674 5cSCd2f3UvMr6zWHgHu94vGZLZxh/ZBIjP0AMy6abpJqTIitypRtCesOCoxhbYLvgMFe KmKv7GUmRCXpQfaBOwkdY654OpkfuZgKNwmhvEu7jNVgyAOEFSLN1nLYnXY4EwucXxKx ul8w== MIME-Version: 1.0 X-Received: by 10.68.52.231 with SMTP id w7mr3679519pbo.19.1382179744226; Sat, 19 Oct 2013 03:49:04 -0700 (PDT) In-Reply-To: <52625779$0$29981$c3e8da3$5496439d@news.astraweb.com> References: <1df612d9-27a0-4f06-9b0c-a8d7fd9bf257@googlegroups.com> <52625779$0$29981$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 19 Oct 2013 21:49:04 +1100 Subject: Re: Python was designed (was Re: Multi-threading in Python vs Java) 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: 84 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382179753 news.xs4all.nl 15932 [2001:888:2000:d::a6]:44294 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57090 On Sat, Oct 19, 2013 at 8:57 PM, Steven D'Aprano wrote: > On Wed, 16 Oct 2013 23:49:02 -0700, Peter Cacioppi wrote: > >> I don't know if I want to step into the flames here, > > Go on, be bold! You learn a lot by making bold claims and having them > shot down. Yes, it's a very effective technique. I just learned another meaning of the word "trepan" via Savoynet that way. (It's a synonym for its anagram "entrap", as well as being a surgical operation on the skull. So now you know, too!) >> Even Python, which isn't strongly typed, >> manages polymorphism by allowing the self argument to a sub-class >> of the method class. > > I must admit I don't really understand what this sentence is supposed to > mean. As I understand it, there's a little word missing: "... allowing the self argument to BE a subclass...". That is, in this example: class A: def foo(self): return "spam" class B(A): pass x=B() print(x.foo()) the method named foo and defined in class A might not get, as its 'self' argument, an instance of class A, but might instead get a subclass thereof. Thus, polymorphism. Similarly, this C example cheats a bit, but does work: struct A { /* ... declare members here */ } struct B { struct A base; /* ... more members */ } int foo(struct A *self) { /* ... */ } int main() { struct B obj; foo((struct A *)&obj); } It depends on the compiler not tinkering with the layout of the structure at all, which I don't believe is guaranteed but is fairly safe to assume. (The equivalent C++ code could use real inheritance, and then it is guaranteed, plus the pointer can be cast implicitly. But we already know C++ does object oriented code more cleanly.) As far as foo() is concerned, it's been given a 'struct A', albeit one with a few extra members after it. >> True object oriented programming >> seems to require proper support from >> the language itself, because the run-time resolution of the "this/self" >> reference needs specific constructs in the language. > > Again, I don't understand what you are trying to say here. Provided that > the "this/self" reference has a type, what more does the language need to > provide? The reference itself is enough to identify the instance (since > it is the instance!) and the instance's type is enough to identify the > type (since it is the type!). See above C example - except that true support would include implicit upcasting, and would thus disallow cross-casting (which the C example above would have problems with - you could cast any pointer to any type with the exact same syntax and no compiler warning or error). ChrisA