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=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:ac8:12c2:0:b0:3a8:1066:8859 with SMTP id b2-20020ac812c2000000b003a810668859mr1642000qtj.157.1674765569758; Thu, 26 Jan 2023 12:39:29 -0800 (PST) X-Received: by 2002:a05:6830:10d9:b0:684:a0bb:75e0 with SMTP id z25-20020a05683010d900b00684a0bb75e0mr2088346oto.82.1674765569512; Thu, 26 Jan 2023 12:39:29 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 26 Jan 2023 12:39:29 -0800 (PST) In-Reply-To: <9c7cccd9-733f-49a8-b482-087ccb14b58dn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=174.26.246.21; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 174.26.246.21 References: <9c7cccd9-733f-49a8-b482-087ccb14b58dn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9d25946b-99ab-433f-99db-14057ca9088fn@googlegroups.com> Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax From: Jerry Injection-Date: Thu, 26 Jan 2023 20:39:29 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:64893 List-Id: On Sunday, January 22, 2023 at 2:34:19 PM UTC-7, ...@gmail.com wrote: > Dear ADA lovers,=20 > with stack allocation of Real_Vector ( 1 .. N ) when N >=3D 100,000 I get= STACK_OVERFLOW ERROR while trying to check how fast operator overloading i= s working for an expression=20 Leo's answer is responsive to the OP but seems to have gotten buried in an = amazingly long discussion which I haven't read. This answer appeared here y= ears ago (was it you, Leo?) and I have used it ever since. If there needs t= o be a long discussion maybe it could be about why this workaround is neces= sary. I will pull out Leo's answer from his post and put my version here: type Real_Vector_Access is access Real_Vector; then x_Ptr : Real_Vector_Access :=3D new Real_Vector(0 .. N - 1); x : Real_Vector renames x_Ptr.all; That's all. All the overloaded operators work as though the vector was decl= ared from the stack. If you have code which formerly used stack allocation = (of x, in this example), it will work without modification with this trick. Jerry