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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:2c4f:: with SMTP id s76-v6mr4320954ios.117.1531577918034; Sat, 14 Jul 2018 07:18:38 -0700 (PDT) X-Received: by 2002:aca:c6ca:: with SMTP id w193-v6mr2027207oif.1.1531577917873; Sat, 14 Jul 2018 07:18:37 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!d7-v6no3513988itj.0!news-out.google.com!l67-v6ni3813itl.0!nntp.google.com!d7-v6no3513984itj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 14 Jul 2018 07:18:37 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=71.171.111.51; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 71.171.111.51 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <40d568da-4715-42de-8e28-98da39a5c974@googlegroups.com> Subject: Visibility of Indexing aspects From: Jere Injection-Date: Sat, 14 Jul 2018 14:18:38 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:53805 Date: 2018-07-14T07:18:37-07:00 List-Id: I was going through an Ada library and noticed that they were able to add an indexing aspect to a type in the private section of a package but have the indexing work for types declared using the public view of the type. It's a neat feature, but I wasn't sure if this was intentional or a GNAT bug? I searched through sections 13.1 and 4.1.6 of the RM, but no mention that I could find of the private/public requirements for the Variable_Indexing and Constant_Indexing aspects. Is there something I missed in the RM, is this a GNAT bug, or something else? Reference example compiled in GCC 8.1: with Ada.Text_IO; use Ada.Text_IO; procedure jdoodle is package Containers is type Container is private; private type Container_Array is array(1..20) of aliased Integer; type Container is tagged record Data : Container_Array := (others => 0); end record with Variable_Indexing => Reference; type Reference_Holder (Element : not null access Integer) is limited null record with Implicit_Dereference => Element; function Reference (Self : aliased in out Container; Index : Positive) return Reference_Holder is (Element => Self.Data(Index)'Access); end Containers; C : aliased Containers.Container; begin for Index in 1 .. 20 loop C(Index) := Index; Put_Line(Integer'Image(C(Index))); end loop; end jdoodle;