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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.20.2 with SMTP id 2mr15449647iou.16.1510672795544; Tue, 14 Nov 2017 07:19:55 -0800 (PST) X-Received: by 10.157.51.145 with SMTP id u17mr716850otc.7.1510672795458; Tue, 14 Nov 2017 07:19:55 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!m191no2756611itg.0!news-out.google.com!193ni3182iti.0!nntp.google.com!l196no3334638itl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 14 Nov 2017 07:19:55 -0800 (PST) In-Reply-To: <79108071-7d76-4276-bc14-268bc1b74b8a@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:511:c903:74cf:caed; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:511:c903:74cf:caed References: <1c20fe22-ba3c-4db4-a18d-c922e3d04de5@googlegroups.com> <79108071-7d76-4276-bc14-268bc1b74b8a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6f3764b9-4260-4ebd-9a10-7cc47a5647b9@googlegroups.com> Subject: Re: Trying to declare an array from the heap from inside a record declaration From: Robert Eachus Injection-Date: Tue, 14 Nov 2017 15:19:55 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2432 X-Received-Body-CRC: 1950999352 Xref: feeder.eternal-september.org comp.lang.ada:48885 Date: 2017-11-14T07:19:55-08:00 List-Id: On Friday, November 10, 2017 at 3:10:46 AM UTC-5, AdaMagica wrote: > Because Ada syntax does not allow it. > > The question should be: Why does Ada not allow this? Ask the language lawywers! (I myself am not in favour of this idea (renamings inside a record).) -- Probably because the result would not be what the user wants. If you -- allocate the array on the heap: X_Ptr : constant Real_Vector_Access := new Real_Vector(M .. N); -- You can then create a record containing 'X': type Foo is record X: Real_Vector_Access := X_Ptr; end record; -- And you have data on the heap. If you want to access elements of X_Ptr -- incuding to assign to them Foo.X(1,2) works. If you want to create a copy -- of X_Ptr.all (or Foo.X.all) you need the all. If you just want to copy -- the pointer, no .all, and that is probably what you should be doing -- anyway. I assume you put the object on the heap because it was too big -- to fit on the stack, or you wanted to pass it around (in a compact form).