* Re: Checking Access Parameters to Procedures
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
1 sibling, 0 replies; 3+ messages in thread
From: David Botton @ 2000-03-06 0:00 UTC (permalink / raw)
"This" can not be NULL as it is passed in by "access". In the event that you
would like to pass in a NULL value, you would have to redefine your
procedure to have an in paramter of an access type.
For example:
package tst_pkg is
type my_ttype is tagged private;
type My_ttype_Access is access all My_ttype'Class;
procedure tst_proc(this : My_Ttype_Access);
Andy Askey wrote in message ...
>I want to check if a value passed into a procedure is NULL. For
>example:
> procedure tst_proc(this : access my_ttype'class);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Checking Access Parameters to Procedures
@ 2000-03-06 0:00 Andy Askey
2000-03-06 0:00 ` David Botton
2000-03-07 0:00 ` Mark Lundquist
0 siblings, 2 replies; 3+ messages in thread
From: Andy Askey @ 2000-03-06 0:00 UTC (permalink / raw)
Another, probably simple, question....
I want to check if a value passed into a procedure is NULL. For
example:
package tst_pkg is
type my_ttype is tagged private;
procedure tst_proc(this : access my_ttype'class);
private
type my_ttype is tagged
record
i : integer;
end record;
end tst_pkg;
package body tst_pkg is
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?
Thanx.
--
Andy Askey
ajaskey@mindspring.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Checking Access Parameters to Procedures
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
1 sibling, 0 replies; 3+ messages in thread
From: Mark Lundquist @ 2000-03-07 0:00 UTC (permalink / raw)
To: Andy Askey
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).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-03-07 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox