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-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: not null Date: 05 Mar 2009 09:49:53 +0100 Organization: Jacob Sparre Andersen Sender: sparre@jspa-nykredit Message-ID: <87eixcmk0e.fsf@nbi.dk> References: <49ae93bc$0$31872$9b4e6d93@newsspool3.arcor-online.net> <761a4fb8-de91-43b3-b420-55dbc06a61e7@k9g2000prh.googlegroups.com> NNTP-Posting-Host: 94.191.240.5.bredband.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: munin.nbi.dk 1236242996 4310 94.191.240.5 (5 Mar 2009 08:49:56 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 5 Mar 2009 08:49:56 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Xref: g2news2.google.com comp.lang.ada:4934 Date: 2009-03-05T09:49:53+01:00 List-Id: Adam Beneschan wrote: > Hyman Rosen wrote: > > [...] he's talking about having null references at all, so Ada is > > no better. > > I'm having difficulty understanding the point. You have to have the > idea of the lack of a reference. > [...] Suppose that access values in Ada were not allowed to have > null values, and (for a linked list) you needed the concept of a > value that may or may not refer to another object. You could write > this as a variant record: > > type Obj_Reference (Present : Boolean) is record > case Present is > when True => > Ref : Obj_Access; -- may not be null > when False => > null; > end case; > end record; > > I just don't see how this is an improvement; it simply shifts the > problem. No. > Whatever mistakes a programmer could in the actual Ada language make > by forgetting to check whether an access value is null, he could > make in the above example by forgetting to check the Present > discriminant. No. The _compiler_ checks the discriminant. The programmer will get a Constraint_Error if he tries to use "Ref" while "Present" is false. And he can't change "Present" to true without also assigning "Ref" a value. Greetings, Jacob -- "For there are only two reasons why war is made against a republic: The one, to become lord over her: the other, the fear of being occupied by her." -- Nicolo Machiavelli