comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: usefulness of "data hiding"
Date: Sun, 18 Jan 2009 15:17:04 +0100
Date: 2009-01-18T15:17:06+01:00	[thread overview]
Message-ID: <uk6efy5hnbo3$.3m9zxvuvyt25$.dlg@40tude.net> (raw)
In-Reply-To: c3c50c78-61f5-4961-bc6e-f8dcc71d625e@y1g2000pra.googlegroups.com

On Sun, 18 Jan 2009 05:07:40 -0800 (PST), Graham Stark wrote:

> On Jan 16, 8:57�am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> 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



  reply	other threads:[~2009-01-18 14:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-16  0:51 usefulness of "data hiding" Russ P.
2009-01-16  1:08 ` Russ P.
2009-01-16  1:33 ` Adam Beneschan
2009-01-17 19:05   ` Marc A. Criley
2009-01-19 16:15     ` Adam Beneschan
2009-01-16  8:57 ` Dmitry A. Kazakov
2009-01-16 23:23   ` sjw
2009-01-17  8:53     ` Dmitry A. Kazakov
2009-01-18 13:07   ` Graham Stark
2009-01-18 14:17     ` Dmitry A. Kazakov [this message]
2009-01-16 17:21 ` Nicholas Collin Paul Gloucester
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox