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,ec21c3c7cdc7ff3e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: private types References: <1142279908.327131.230200@j52g2000cwj.googlegroups.com> From: Brian May Date: Tue, 14 Mar 2006 18:44:09 +1100 Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:cLcNscplnKa47B8Zkblrm2sDlQ8= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: snoopy.microcomaustralia.com.au X-Trace: news.melbourne.pipenetworks.com 1142322250 202.173.153.89 (14 Mar 2006 17:44:10 +1000) X-Complaints-To: abuse@pipenetworks.com X-Abuse-Info: Please forward all headers to enable your complaint to be properly processed. Path: g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp.waia.asn.au!202.72.130.18.MISMATCH!quokka.wn.com.au!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:3350 Date: 2006-03-14T18:44:09+11:00 List-Id: >>>>> "Jeffrey" == Jeffrey R Carter writes: >> MyInteger to be made visible outside the scope of PrivateType ? >> Doesnt it make the code less secure(for example,consider an >> "uninitialized" object of type PrivateType.MyInteger). Jeffrey> Because that's what private means in Ada. He does have a point though - some languages will initialise all variables to dummy values - this means you can get predictable results in code that (wrongly) uses them before setting them to a value. In this case it is possible to force initialisation (at least outside the package), as per another poster's suggestion, because it is a private type. Alternatively it is possible to turn it into a record type and provide a default value for the component, as per another post. In other cases it isn't so easy, e.g. any non-private non-record type. In fact, by default (at least last time I checked), gcc (or was that gnat) doesn't check the validity of parameters to functions if the type matches, even though the type hasn't been initialised and may just happen to contain an illegal value. I seem to recall Ada will initialise access types to null, and record components (if defaults given), but nothing else. -- Brian May