comp.lang.ada
 help / color / mirror / Atom feed
* Re: Question: Combination of Access and Constraining
@ 2003-02-20  9:46 Grein, Christoph
  0 siblings, 0 replies; 16+ messages in thread
From: Grein, Christoph @ 2003-02-20  9:46 UTC (permalink / raw)
  To: comp.lang.ada

> type Tp is array (Positive range <>) of Boolean;
> type Tp_Access is access all Tp;
> function Fn (Arg : in Tp_Access) return Natural;

This is not a primitive function of Tp.

> Now I try to call it with the constrained array:
> 
> declare
>   type TpCon is new Tp(1..1);

TpCon does not inherit Fn.

>   Arr : aliased TpCon;
> begin
>   Arr(1) := True;
>   Res := Fn (Arr'Access);
> end;

Why do you use access types?



^ permalink raw reply	[flat|nested] 16+ messages in thread
* Question: Combination of Access and Constraining
@ 2003-02-20  8:06 Papandopulo
  2003-02-20  9:00 ` tmoran
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Papandopulo @ 2003-02-20  8:06 UTC (permalink / raw)


Small Ada question:

I need one function to accept
an array of unknown size of Boolean,
so I declare type and function:

type Tp is array (Positive range <>) of Boolean;
type Tp_Access is access all Tp;

function Fn (Arg : in Tp_Access) return Natural;

Now I try to call it with the constrained array:

declare
  type TpCon is new Tp(1..1);
  Arr : aliased TpCon;
begin
  Arr(1) := True;
  Res := Fn (Arr'Access);
end;

Compiler says on the invocation line:
expected type: Tp_Access defined at ...
found type TpCon defined at ...

I think that access to constrained
type should be convertible to access
to unconstrained type.

So where I am going wrong here ?

Thanx,
George



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

end of thread, other threads:[~2003-02-23 17:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-20  9:46 Question: Combination of Access and Constraining Grein, Christoph
  -- strict thread matches above, loose matches on Subject: below --
2003-02-20  8:06 Papandopulo
2003-02-20  9:00 ` tmoran
2003-02-20  9:29 ` Dmitry A. Kazakov
2003-02-20 15:20   ` Papandopulo
2003-02-20 16:20     ` Dmitry A. Kazakov
2003-02-20 17:58     ` Jeffrey Carter
2003-02-20 20:35       ` Yuri
2003-02-21  1:21         ` Jeffrey Carter
2003-02-21 22:53           ` Yuri
2003-02-23 12:34             ` Simon Wright
2003-02-23 17:50               ` Jeffrey Carter
2003-02-23 17:55               ` John R. Strohm
2003-02-23 17:48             ` John R. Strohm
2003-02-20 13:12 ` David C. Hoos, Sr.
2003-02-20 15:00 ` Matthew Heaney

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