From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,78609accbfa860fe X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: usefulness of "data hiding" Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <72f07ba4-f06d-44bf-9759-0e6f0d0426d0@h20g2000yqn.googlegroups.com> Date: Sun, 18 Jan 2009 15:17:04 +0100 Message-ID: NNTP-Posting-Date: 18 Jan 2009 15:17:06 CET NNTP-Posting-Host: 3b0ebddc.newsspool2.arcor-online.net X-Trace: DXC=;3YbCJ8HjJRFm0Y?OE@2^XA9EHlD;3YcR4Fo<]lROoRQ^YC2XCjHcbYn0UIHeEV2c\DNcfSJ;bb[UIRnRBaCd On Sun, 18 Jan 2009 05:07:40 -0800 (PST), Graham Stark wrote: > On Jan 16, 8:57�am, "Dmitry A. Kazakov" > wrote: >> On Thu, 15 Jan 2009 16:51:38 -0800 (PST), Russ P. wrote: >>> As many of you probably know, Python had no data hiding. >> >> Python is a dynamically typed language. When dynamic typing is considered >> conceptually that inevitably leads you to weak and then to no typing. In an >> effectively untyped framework (this includes massive type inference as >> well), you necessarily have to drop encapsulation. There is nothing to >> hide, and nothing can be hidden. > > There's not much relationship between weak typing and data hiding, is > there? > > The least strongly typed language I know of is PHP > ($s = "x" + 10; is legal, for instance) > but you can have complete encapsulation if you want it: > > class A{ > private $a; > function getA(){ return $this->a; } > function setA( $a ){ $this->a = $a; } > } > > and there are strongly typed languages, like Pascal, where you can't > do this at all. In order to reason about these examples, you should tell me what was dynamic and encapsulated in the examples you provided. I don't know PHP, but "x" and 10 look like literals. That does not sound like dynamic typing. Again, I don't know PHP, but considering Ada's: type A is private; private type A is new Integer; Here the operation "+" of A is hidden. In a dynamically typed language you cannot do it, the interface of any type has all possible operations. you possibly can override implementations, but you cannot remove them. I don't know what PHP would bind public "+" to in a comparable case. Would it be to "method-not-understood" or to the original "+". Any choice breaks encapsulation to me. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de