From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:620a:1278:b0:705:74fe:b39a with SMTP id b24-20020a05620a127800b0070574feb39amr1146196qkl.616.1674424356542; Sun, 22 Jan 2023 13:52:36 -0800 (PST) X-Received: by 2002:a05:6870:7a10:b0:132:79b1:f85 with SMTP id hf16-20020a0568707a1000b0013279b10f85mr1997900oab.274.1674424356310; Sun, 22 Jan 2023 13:52:36 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 22 Jan 2023 13:52:36 -0800 (PST) Injection-Info: google-groups.googlegroups.com; posting-host=157.143.56.236; posting-account=Wbe3fAoAAAALa8UT9MWTy6mw2ahlRJms NNTP-Posting-Host: 157.143.56.236 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Implicit_Dereference for Real_Vectors ? From: Jim Paloander Injection-Date: Sun, 22 Jan 2023 21:52:36 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2710 Xref: reader01.eternal-september.org comp.lang.ada:64847 List-Id: Dear ADA experts, is it possible to extend an inherent ADA package such Real_Arrays with some= thing like this? type Accessor (Data: not null access Real_Vector) is limited private with I= mplicit_Dereference =3D> Data; In the hope that I could somehow declare: A: Accessor :=3D new Real_Vector ( 1 .. N ); B: Accessor :=3D new Real_Vector ( 1 .. N ); X: Accessor :=3D new Real_Vector ( 1 .. N ); So I could write a statement: X :=3D A + B; instead of X.all :=3D A.all + B.all; since I am forced to use heap allocation for N > 100,000? Sorry for my igno= rance but I am new to ADA and I cannot find enough documentation. Container= s seem to be awful in terms of syntax for mathematical programming and lin= ear algebra, and the fact that Real_Arrays allow clean syntax for operator = overloading only if allocated on the limited stack is really extremely fru= strating. I totally understand the preference for stack over heap for certa= in applications, but for the applications I have in mind the size of the pr= oblem is determined at runtime. There is no way to know it in advance. I tr= ied -D1000m -d1000m in the binder options to no avail. Always I get the STA= CK_OVERFLOW error. My only option is heap. Moreover, I would expect that AD= A's Numerics are as efficient as Fortran's overloaded operators and no temp= orary objects are generated when you do something like: X :=3D A + B + C + A + B; Unfortunately ADA introduces a temporary for every addition that is added t= o the next creating a 2nd temporary and so on. temp1 :=3D A+B; temp2 :=3D C+temp1; temp3 :=3D B+temp2; temp4 :=3D A+temp3;= X :=3D temp4;