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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38b27bed88e97415 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-20 01:30:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Question: Combination of Access and Constraining Date: Thu, 20 Feb 2003 10:29:59 +0100 Message-ID: <9d795v0h3qa2922u8vodfhpfvprpre6ak2@4ax.com> References: <1d13e1b4.0302200006.70207b86@posting.google.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1045733399 52461526 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:34261 Date: 2003-02-20T10:29:59+01:00 List-Id: On 20 Feb 2003 00:06:15 -0800, papand0pul0@yahoo.com (Papandopulo) wrote: >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; Pointers are inherently bad. Why not: function Fn (Arg : Tp) return Natural; >Now I try to call it with the constrained array: > >declare > type TpCon is new Tp(1..1); ^^^^^^ But this is another type! Probably you meant a subtype: subtype TpCon is 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 ? You are mixing types and subtypes. If you want just to put a constraint on a type, declare a constrained subtype. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de