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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!aioe.org!qYcU9JfyUhY8OJVCu5UZdA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax Date: Mon, 23 Jan 2023 09:28:46 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <9c7cccd9-733f-49a8-b482-087ccb14b58dn@googlegroups.com> <2801afb2-045f-4fec-b41e-f83b2c80e672n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="43704"; posting-host="qYcU9JfyUhY8OJVCu5UZdA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:64868 List-Id: On 2023-01-22 23:36, Jim Paloander wrote: > I was not sure whether or not it can be avoided with Implicit_Dereference, > > type Accessor (Data: not null access Element) is limited private > with Implicit_Dereference => Data; If you create a new wrapper type, anyway, then it is easier to define operations directly on that new type. > Otherwise what you described for operator+ one has to do for every operator overloaded inside Real_Arrays package. You should not use the standard library anyway. It is not intended for large problems, which require specific approaches and methods, like sparse matrices, concurrent processing and so on. > The optimal way to work large linear algebra problem is what you describe because unfortunately ADA does not allow what Fortran does since 30 years ago or more. I am not sure what you mean. It is quite possible to design a wrapper datatype allocating vectors/matrices in the pool. E.g. Ada's Unbounded_String is such a thing. Real_Arrays were not designed this way because see above. > But in C++ you can reproduce the same functionality as Fortran using Expression Templates and Template Metaprogramming. Nothing prevents you from wrapping Real_Array in a generic way: generic with package Real_Arrays is new Numerics.Generic_Real_Arrays (<>); package Generic_Pool_Real_Arrays is ... end Generic_Pool_Real_Arrays; > Perhaps ADA should allow something like that. Because for maintainability reasons the best would be to write the mathematical expressions as close as possible to the mathematical formulas. There is no problem with that as you can define operations on pointers. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de