From: Simon Smith <Simon@skcs.co.uk>
Subject: Re: What is the point of Private?
Date: Sun, 01 May 2005 23:57:21 +0100
Date: 2005-05-01T23:57:21+01:00 [thread overview]
Message-ID: <d53mq8$4bs$1@news.freedom2surf.net> (raw)
In-Reply-To: <dCAce.1362$%K6.833@newsfe5-gui.ntli.net>
thanks for all the replies.
All beginning to make sense now :-)
chris wrote:
> It's there for two reasons. It hides the implementation from clients of
> the code and makes the compilers job easier. The decision seems to be
> that the compiler should be able to determine how much space something
> will take at compile time*. This means they had to put the
> representation in the spec, so the compiler knew what to allocate.
>
> The alternatives are to leave everything public or to put the
> representation in the body. Making everything public means someone can
> adversely manipulate the contents of your data structures. They can
> break the rules, and mess up the software. Completely hiding the
> representation by putting it in the body has a different trade off. On
> the one hand, you can substitute any representation by changing the body
> alone, but on the other hand the compiler won't know how big the data
> structure is and it has to treat all things the same way (by wrapping or
> boxing them up - which has a cost).
>
> It's a trade off. The Ada people chose to put it in the spec because it
> simplified the compiler, and it best suited their over all goals. Other
> languages allow you to completely hide the representation in the
> implementation. e.g. SML, Ocaml. Some make it public.
>
>> Why is it there? I am sure I have heard talk that its to stop the
>> client from seeing exactly how the data is stored/manipulated however
>> if people really did want to know this wouldn't they just scroll down
>> the ada spec file and find out for themselves or am I missing
>> something here?
>
>
> Client code can't do that though. This means someone who uses the
> compiled package can't see how it's implemented, but the maintainer can.
>
>
>
> Chris
>
> *There are probably other reasons too, I don't know what they are though.
prev parent reply other threads:[~2005-05-01 22:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-28 23:22 What is the point of Private? Simon Smith
2005-04-28 23:40 ` Ed Falis
2005-04-29 3:14 ` Jeffrey Carter
2005-04-29 9:07 ` Peter Amey
2005-04-30 3:27 ` Jeffrey Carter
2005-04-30 0:49 ` chris
2005-05-01 22:57 ` Simon Smith [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox