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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8de940f14e471675 X-Google-Attributes: gid103376,public From: Mark Lundquist Subject: Re: Checking Access Parameters to Procedures Date: 2000/03/07 Message-ID: <38C56EF1.3057F00D@rational.com>#1/1 X-Deja-AN: 594419880 Content-Transfer-Encoding: 7bit References: To: Andy Askey X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Rational Software Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-07T00:00:00+00:00 List-Id: 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).