by "jimmaureenrogers@[EMAIL PROTECTED]
" <jimmaureenrogers@[EMAIL PROTECTED]
Mar 30, 2008 at 02:34 PM
On Mar 30, 2:58 pm, ma740...@[EMAIL PROTECTED]
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