comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: ada and final/sealed classes
Date: Sun, 17 Oct 2004 15:36:03 GMT
Date: 2004-10-17T15:36:03+00:00	[thread overview]
Message-ID: <u1xfx9r73.fsf@earthlink.net> (raw)
In-Reply-To: 1c2f5137.0410130438.3ea08553@posting.google.com

onsbomma@hotmail.com (Hans Van den Eynden) writes:

> I want to prevent someone from inheriting from a type I made (for
> security purposes). I am a junior Ada programmer and I know this
> possible in Java (final class) and C# (sealed class). Is this also
> possible in Ada???

Not really, no.

Ada is designed such that there is a lexical distinction for a type that
has visibility to the representation of another type.  

The way this works is that derived types in a class that have access to
the representation of the parent type must be declared in child
packages:

package P is
   type T is tagged limited private;
   ...
private
   type T is tagged limited record
     ... -- lots of secret stuff here
   end record;
end P;

package P.C is
   type NT is new T with private;
   ...
private
   type NT is new T with record
      ... -- more secret stuff here
   end record;
end P.C;

Here, type P.C.NT has visibility to the private presentation of type
P.T.  That fact is ennunciated since NT is declared in the same
subsystem (rooted at package P) as type T.




  parent reply	other threads:[~2004-10-17 15:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1c2f5137.0410130438.3ea08553@posting.google.com>
2004-10-13 13:31 ` ada and final/sealed classes Dmitry A. Kazakov
2004-10-17 15:36 ` Matthew Heaney [this message]
2004-10-18  0:20   ` Brian May
2004-10-18  7:46 ` Martin Krischik
replies disabled

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