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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,92a5558d9ff5b0f2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread3.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: ada and final/sealed classes References: <1c2f5137.0410130438.3ea08553@posting.google.com> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 17 Oct 2004 15:36:03 GMT NNTP-Posting-Host: 64.185.133.124 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.atl.earthlink.net 1098027363 64.185.133.124 (Sun, 17 Oct 2004 08:36:03 PDT) NNTP-Posting-Date: Sun, 17 Oct 2004 08:36:03 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:5365 Date: 2004-10-17T15:36:03+00:00 List-Id: 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.