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 Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: private types Date: 25 Mar 2006 16:40:46 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1142279908.327131.230200@j52g2000cwj.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1143322846 20909 192.74.137.71 (25 Mar 2006 21:40:46 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 25 Mar 2006 21:40:46 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:3610 Date: 2006-03-25T16:40:46-05:00 List-Id: Justin Gombos writes: > On 2006-03-18, Robert A Duff wrote: > > > > In Ada, if an object of an access type has no explicit initial > > value, you can't easily tell whether that means "null is a > > meaningful value for this variable, and that's the default I want" > > versus "this variable will be initialized to a meaningful (non-null) > > value later". > > If you want to distinguish between the two possiblities, you could > explicitly initialize your pointers to null in the first case, and not > in the second. Yes, that's a reasonable style, and I use it myself. But there's no compiler support for that style. As far as the language and compiler are concerned, "X: T" and "X: T := null" mean EXACTLY the same thing. It's hard to tell whether the programmer means the same thing in these cases. >... I rarely use access types, So you rarely create trees, linked list, etc? >... and I probably wouldn't do > that myself simply because I find the distinction unimportant for > access types. Regardless, I'm not going to give up the benefit of > having this distinction on non-access scalars simply because my access > type declarations don't have it. > > > This is exactly analogous to the case with integers -- if they were > > default-initialized to zero, you can't easily tell whether zero is > > intended as a meaningful initial value, versus later initialization > > to a meaningful value. > > Integers, and other non-access scalars are different in this case > because you cannot expect zero to have the same meaning. Zero has a > universal meaning with access types, No, zero has no meaning with access types! >... but it could be in range or out > of range for any other type. The ARM selects access types > specifically to get a default initialization of zero for this reason. There is no "default initialization of zero". There is a default-init to null, which has nothing to do with zero (according to the Ada standard). - Bob