comp.lang.ada
 help / color / mirror / Atom feed
* How to do null comparision with pointers in ADA83?
@ 2013-10-25 18:12 seshucherukuri
  2013-10-25 18:18 ` Adam Beneschan
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: seshucherukuri @ 2013-10-25 18:12 UTC (permalink / raw)


Hello,
In ADA83, i could not able to do null comparision of my pointer value.
here, my pointer is of array type.

Is there any solution for this.

Thanking you in advance.

Regards,
Seshukumar.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 18:12 How to do null comparision with pointers in ADA83? seshucherukuri
@ 2013-10-25 18:18 ` Adam Beneschan
  2013-10-25 18:33 ` seshucherukuri
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Adam Beneschan @ 2013-10-25 18:18 UTC (permalink / raw)


On Friday, October 25, 2013 11:12:00 AM UTC-7, seshuch...@gmail.com wrote:
> Hello,
> 
> In ADA83, i could not able to do null comparision of my pointer value.
> here, my pointer is of array type.
> 
> Is there any solution for this.
> 
> Thanking you in advance.

We really need to see the code.  But here's my first guess: When you declare an access type in a package, the "=" operator that lets you compare values of the access type is also declared in the same package.  In another package, you can't use the "=" operator unless the names in the first package are visible.  So this won't work if you're not inside package P:

    Acc : P.Access_Type;
begin
    if Acc = null then ...

You'd need to either put "use P;" somewhere, or do something like this:

    if P."=" (Acc, null) then ...

or you could use a rename to make "=" visible if you don't want to use "use P":

    function "=" (Left, Right : P.Access_Type) return boolean
        renames P."=";

and now you can use = as an operator everywhere that this renaming declaration is visible.

If this isn't the problem, then I think we need to see some code.

                                    -- Adam



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 18:12 How to do null comparision with pointers in ADA83? seshucherukuri
  2013-10-25 18:18 ` Adam Beneschan
@ 2013-10-25 18:33 ` seshucherukuri
  2013-10-25 18:40   ` Adam Beneschan
  2013-10-25 19:27 ` seshucherukuri
  2013-10-25 19:40 ` Seshu Kumar
  3 siblings, 1 reply; 9+ messages in thread
From: seshucherukuri @ 2013-10-25 18:33 UTC (permalink / raw)


On Friday, October 25, 2013 1:12:00 PM UTC-5, seshuch...@gmail.com wrote:
> Hello, In ADA83, i could not able to do null comparision of my pointer value. here, my pointer is of array type. Is there any solution for this. Thanking you in advance. Regards, Seshukumar.

Hello,

Here my code is 
type AVL_Node_Ref is access AVL_Node;

procedure Search_Insert (T : in out AVL_Tree;
                            Element : VCAST_MCDC_Statement_Ptr;
                            Node : in out AVL_Node_Ref;
                            Increased : in out Boolean;
                            Inserted : out Boolean)

begin
if Node = null then
....

Here, in the above code Node = null is not taking....
any quick inputs...
I want to compile for ADA83.
Thanks,
Seshu.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 18:33 ` seshucherukuri
@ 2013-10-25 18:40   ` Adam Beneschan
  2013-10-25 18:48     ` seshucherukuri
  0 siblings, 1 reply; 9+ messages in thread
From: Adam Beneschan @ 2013-10-25 18:40 UTC (permalink / raw)


On Friday, October 25, 2013 11:33:14 AM UTC-7, seshuch...@gmail.com wrote:

> Here my code is 
> 
> type AVL_Node_Ref is access AVL_Node;
> 
> procedure Search_Insert (T : in out AVL_Tree;
>                             Element : VCAST_MCDC_Statement_Ptr;
>                             Node : in out AVL_Node_Ref;
>                             Increased : in out Boolean;
>                             Inserted : out Boolean)
> 
> begin
> if Node = null then

Is the place where AVL_Node_Ref is declared in the "private" part of a package?  And is there something that says "type AVL_Node_Ref is private;"?

                        -- Adam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 18:40   ` Adam Beneschan
@ 2013-10-25 18:48     ` seshucherukuri
  2013-10-25 18:56       ` Adam Beneschan
  0 siblings, 1 reply; 9+ messages in thread
From: seshucherukuri @ 2013-10-25 18:48 UTC (permalink / raw)


On Friday, October 25, 2013 1:40:30 PM UTC-5, Adam Beneschan wrote:
> On Friday, October 25, 2013 11:33:14 AM UTC-7, seshuch...@gmail.com wrote: > Here my code is > > type AVL_Node_Ref is access AVL_Node; > > procedure Search_Insert (T : in out AVL_Tree; > Element : VCAST_MCDC_Statement_Ptr; > Node : in out AVL_Node_Ref; > Increased : in out Boolean; > Inserted : out Boolean) > > begin > if Node = null then Is the place where AVL_Node_Ref is declared in the "private" part of a package? And is there something that says "type AVL_Node_Ref is private;"? -- Adam

Yes you are correct.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 18:48     ` seshucherukuri
@ 2013-10-25 18:56       ` Adam Beneschan
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Beneschan @ 2013-10-25 18:56 UTC (permalink / raw)


On Friday, October 25, 2013 11:48:05 AM UTC-7, seshuch...@gmail.com wrote:

If AVL_Node_Ref is declared "type AVL_Node_Ref is private;" in package P, then the only places where the program can tell it's an access type are in the private part of P (after the complete declaration is seen), and in the body of P.  (And, in Ada 95+, in some places in child packages.)  Here, if you're in another package, it won't be able to tell that AVL_Node_Ref is an access type, even if you say "use P;".  It only knows that it's a private type.  You should be able to compare two AVL_Node_Refs, since "=" is still defined on private types.  But you can't compare an AVL_Node_Ref to null, since it's not allowed to know AVL_Node_Ref is an access type.

When a package declares a private type, it also has to decide what operations on that type it wants to provide for other packages to use.  Here, you probably want to declare a function like Is_Null in the public part of the package.  Now other packages can use that function without having to know anything about AVL_Node_Ref's full definition.

                             -- Adam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 18:12 How to do null comparision with pointers in ADA83? seshucherukuri
  2013-10-25 18:18 ` Adam Beneschan
  2013-10-25 18:33 ` seshucherukuri
@ 2013-10-25 19:27 ` seshucherukuri
  2013-10-25 19:34   ` Adam Beneschan
  2013-10-25 19:40 ` Seshu Kumar
  3 siblings, 1 reply; 9+ messages in thread
From: seshucherukuri @ 2013-10-25 19:27 UTC (permalink / raw)


On Friday, October 25, 2013 1:12:00 PM UTC-5, seshuch...@gmail.com wrote:
> Hello, In ADA83, i could not able to do null comparision of my pointer value. here, my pointer is of array type. Is there any solution for this. Thanking you in advance. Regards, Seshukumar.

Thanks for the quick response.
I am new to ADA environment..,

Here firstly i doubt simple pointer comparision to null is not working.
In different place of code i executed

ptr is an obj of array type.
if ptr = null then
This does not compile for me.

Do you think issue with my compiler?

Thanks,
Seshu.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 19:27 ` seshucherukuri
@ 2013-10-25 19:34   ` Adam Beneschan
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Beneschan @ 2013-10-25 19:34 UTC (permalink / raw)


On Friday, October 25, 2013 12:27:26 PM UTC-7, Seshu Kumar wrote:

> Here firstly i doubt simple pointer comparision to null is not working. 
> In different place of code i executed
> 
> ptr is an obj of array type.
> if ptr = null then

I take it this is a different problem than the one we've been discussing?  Once again, we need to see the code.  "ptr is an obj of array type" is not a valid Ada statement, and I can't guess what Ada code you actually wrote.

                               -- Adam

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to do null comparision with pointers in ADA83?
  2013-10-25 18:12 How to do null comparision with pointers in ADA83? seshucherukuri
                   ` (2 preceding siblings ...)
  2013-10-25 19:27 ` seshucherukuri
@ 2013-10-25 19:40 ` Seshu Kumar
  3 siblings, 0 replies; 9+ messages in thread
From: Seshu Kumar @ 2013-10-25 19:40 UTC (permalink / raw)


On Friday, October 25, 2013 1:12:00 PM UTC-5, Seshu Kumar wrote:
> Hello, In ADA83, i could not able to do null comparision of my pointer value. here, my pointer is of array type. Is there any solution for this. Thanking you in advance. Regards, Seshukumar.

Ok.. Finally we found the issue is with our compiler.
We cross checked in GNAT GPS compiler for ADA83 and it worked.

This is internal problem.
Thanks for your inputs.

Seshukumar.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-10-25 19:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-25 18:12 How to do null comparision with pointers in ADA83? seshucherukuri
2013-10-25 18:18 ` Adam Beneschan
2013-10-25 18:33 ` seshucherukuri
2013-10-25 18:40   ` Adam Beneschan
2013-10-25 18:48     ` seshucherukuri
2013-10-25 18:56       ` Adam Beneschan
2013-10-25 19:27 ` seshucherukuri
2013-10-25 19:34   ` Adam Beneschan
2013-10-25 19:40 ` Seshu Kumar

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