comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Lundquist <mark@rational.com>
To: Andy Askey <ajaskey@mindspring.com>
Subject: Re: Checking Access Parameters to Procedures
Date: 2000/03/07
Date: 2000-03-07T00:00:00+00:00	[thread overview]
Message-ID: <38C56EF1.3057F00D@rational.com> (raw)
In-Reply-To: q6r8cscb2h8c9pmjhei7q1fk8hn6gimfpj@4ax.com

Andy Askey wrote:

>    procedure tst_proc(this : access my_ttype'class) is
>    begin
>       if (this = NULL) then
>         ....
>      end if;
>    end tst_proc;
> end tst_pkg;
>
> This does not compile so I tried every combination I can think of and
> nothing worked so far.  How can I test if "this" is a NULL pointer?

The bad news: you can't.
The good news: you don't have to.

When you say "this : access my_ttype'class", you're defining an
anonymous general access-to-variable type, and anonymous access types do
not have the value Null.  Null is only a value of named access types.
That's why the compiler doesn't know what you mean.  At run-time, the
only way you could get a null value to try to pass in "this" would be
through an implicit type conversion from a named access type, and in
that case the conversion will raise Constraint_Error (like any other
conversion where there's no corresponding value of the target type).






      parent reply	other threads:[~2000-03-07  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-06  0:00 Checking Access Parameters to Procedures Andy Askey
2000-03-06  0:00 ` David Botton
2000-03-07  0:00 ` Mark Lundquist [this message]
replies disabled

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