access types and head pains 
Author Message
 access types and head pains

hi,
    I have the following situation.  I'm writing a driver that can be run on my
system.  I want to test it by writing virtually to a file.

The problem is i had the following code

package X is

    type A is private
    type A_ac is access all A;
...

    procedure Do_S (av : in out A_ac; v : any_type );

    --  with body
    --    is begin
    --        av.v := v; etc

end X;

procedure test is
    at : aliased A;
begin
    Do_S (at'unchecked_access, 2);
end test;

i got an error that said "at actual must be a variable".  What's wrong?

The idea is that the driver will work with two different kinda things in the
same procedure.  "at" can be declared in program or be a chunk of memory of the
same size. Any hints?

Thanks,
Chris



Wed, 12 Nov 2003 07:59:23 GMT  
 access types and head pains

Quote:

> package X is

>     type A is private
>     type A_ac is access all A;
> ...

>     procedure Do_S (av : in out A_ac; v : any_type );

>     --  with body
>     --    is begin
>     --        av.v := v; etc

> end X;

> procedure test is
>     at : aliased A;
> begin
>     Do_S (at'unchecked_access, 2);
> end test;

> i got an error that said "at actual must be a variable".  What's wrong?

> The idea is that the driver will work with two different kinda things in the
> same procedure.  "at" can be declared in program or be a chunk of memory of the
> same size. Any hints?

I suspect your message read "av actual ...". The parameter av is mode in
out, which means Do_S may modify it. You can't change
at'unchecked_access, because then it wouldn't be at'unchecked_access any
more. Unless you have "av := ...;" in Do_S, why not just make it mode
in?

--
Jeff Carter
"I waggle my private parts at your aunties."
Monty python & the Holy Grail



Wed, 12 Nov 2003 12:39:48 GMT  
 access types and head pains

Quote:
> I suspect your message read "av actual ...". The parameter av is mode in
> out, which means Do_S may modify it. You can't change
> at'unchecked_access, because then it wouldn't be at'unchecked_access any
> more. Unless you have "av := ...;" in Do_S, why not just make it mode
> in?

I'll try that.  I'm a little confused though.

(let's change the name "at" to al_t, i quickly wrote down the example with short
identifiers of which at happened to appear, i know it's a reserved word!  i was
tired)

a_ac    is a general access type

if av has mode "in" then how can i modify the fields of the record.  surely this
would be dissallowed or does it mean you can't modify it's existance/null status
but can modify it's data?

Chris



Thu, 13 Nov 2003 00:48:47 GMT  
 access types and head pains

Quote:

> a_ac    is a general access type

> if av has mode "in" then how can i modify the fields of the record.  surely this
> would be dissallowed or does it mean you can't modify it's existance/null status
> but can modify it's data?

Given

Av : in A_Ac

you can't modify Av; within the subprogram Av is a constant. You can,
however, modify the value designated by Av (Av.all); since A_Ac is not
"access constant", Av.all is not a constant.

--
Jeff Carter
"You tiny-brained wipers of other people's bottoms!"
Monty Python & the Holy Grail



Thu, 13 Nov 2003 01:17:48 GMT  
 access types and head pains

Quote:
> Given

> Av : in A_Ac

> you can't modify Av; within the subprogram Av is a constant. You can,
> however, modify the value designated by Av (Av.all); since A_Ac is not
> "access constant", Av.all is not a constant.

thanks for that explanation.  I understand now

Chris Campbell



Thu, 13 Nov 2003 01:31:51 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. type is access cf type is access all?

2. type mismatches/access type

3. Access types vs. Record types as procedure parameters

4. access mode to access type

5. Type resolution & classwide access types

6. Inheritance of abstract types: accessing the parent type (F2003 standard question)

7. How do I access secondary part type?

8. private access to things from arguments of same type

9. Error when accessing low level objects and converting variant to refnum Type

10. Access individual bits of a long data type

11. Accessing Word 8 through its type library with Eiffel

12. Inheritance and Ada (and access types and generics)

 

 
Powered by phpBB® Forum Software