comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: How best to test for NULL in Ada?
Date: Thu, 02 Jul 2015 16:19:22 -0700
Date: 2015-07-02T16:19:22-07:00	[thread overview]
Message-ID: <mn4gr7$97r$2@dont-email.me> (raw)
In-Reply-To: <764f86ed-3b89-4631-b3f3-4d2b1b8d3df0@googlegroups.com>

On 07/02/2015 03:15 PM, NiGHTS wrote:
> I have encountered several situations where I needed to test an access type
> for NULL or not. My instinct is to do something like this:
> 
> if Some_Object /= null then ...

That is correct.

> But many times I get this error:
> 
> invalid operand type for operator "/=" left operand has type
> "Some_Object_Type" defined at ... right operand has an access type

This says that Some_Object is not a value of an access type, so you can't
compare it to null.

> (If you want a specific example, I am trying to test if the Selected Path
> returned by Gtk.Tree_View.Get_Cursor in the GTK Library is valid or NULL. But
> situations like these occur many times in distinct situations so I'm not
> looking for a fix to this specific problem)

The path returned has type Gtk.Tree_Model.Gtk_Tree_Path, which is a tagged
record type. Since it's not an access type, you can't compare it to null. You
have to compare it to a value of type Gtk.Tree_Model.Gtk_Tree_Path.

-- 
Jeff Carter
"What lazy lout left these wires all over the lawn?"
Poppy
98

  reply	other threads:[~2015-07-02 23:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02 22:15 How best to test for NULL in Ada? NiGHTS
2015-07-02 23:19 ` Jeffrey R. Carter [this message]
2015-07-03  0:12   ` Randy Brukardt
2015-07-04  2:02     ` Shark8
2015-07-03  7:30   ` Dmitry A. Kazakov
2015-07-05 23:32 ` NiGHTS
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox