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,9e87e366cae15081 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!c19g2000prf.googlegroups.com!not-for-mail From: "jimmaureenrogers@worldnet.att.net" Newsgroups: comp.lang.ada Subject: Re: if Restrict_Func /= null confusion Date: Sun, 30 Mar 2008 14:34:31 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <95f36a62-b94c-4211-896a-300fa98932b7@x41g2000hsb.googlegroups.com> NNTP-Posting-Host: 75.70.240.233 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1206912871 25686 127.0.0.1 (30 Mar 2008 21:34:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 30 Mar 2008 21:34:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c19g2000prf.googlegroups.com; posting-host=75.70.240.233; posting-account=fZH-XgkAAADP-Rf8L8ppyFIdKUfh90k4 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20653 Date: 2008-03-30T14:34:31-07:00 List-Id: On Mar 30, 2:58 pm, ma740...@gmail.com wrote: > Well folks its been at least 4 years since I've perused and/or written > Ada source. That aside I'm perusing source code written in Ada. So > consider: > > -- used to restrict a variable within a range > -- for example: -PI to +PI > type Restrict_Function is access function (X: Real4) return Real4; > > type Filt_Data is > record > Restrict_Func : Restrict_Function ; > > end record ; > > -- within a procedure we have > Fdata : Filt_Data; > Restrict_Func : Restrict_Function := FData.Restrict_Func ; > > if Restrict_Func /= null then > -- stuff > endif > > At issue: I'm not following the conditional logic 'if (Restrict_Func / > = null)'. Not understanding the impetus behind the check for null. Type Restrict_Function is an access type. It is possible for an instance of Restrict_Function to have a null value. This kind of problem can occur if you are creating an array of Restrict_Function and only some of the elements of the array are set to non-null values. You will encounter a run-time error if you try to dereference a null access value. Jim Rogers