comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry <list_email@icloud.com>
Subject: Re: How to access an array using two different indexing schemes
Date: Sun, 26 Nov 2017 02:31:30 -0800 (PST)
Date: 2017-11-26T02:31:30-08:00	[thread overview]
Message-ID: <95fdc3af-e6fc-41f1-a221-b4eb02166f35@googlegroups.com> (raw)
In-Reply-To: <ovdvnm$3dt$1@gioia.aioe.org>

On Sunday, November 26, 2017 at 1:58:32 AM UTC-7, Dmitry A. Kazakov wrote:
> On 2017-11-26 02:07, Jerry wrote:
> > On Friday, November 24, 2017 at 4:38:10 PM UTC-7, Jerry wrote:
> >> I frequently allocate memory for arrays from the heap, as discussed previously on this list, like this:
> >>
> >> with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays;
> >> procedure Double_Array_2 is
> >>      type Real_Vector_Access is access Real_Vector;
> >>      x_Ptr : Real_Vector_Access := new Real_Vector(-4 .. 3);
> >>          x : Real_Vector renames x_Ptr.all;
> >>      y_Ptr : Real_Vector_Access := new Real_Vector(0 .. 7);
> >>          y : Real_Vector renames y_Ptr.all;
> >> begin
> >>      null;
> >> end Double_Array_2;
> >>
> >> How would I use the 'Address trick in this situation?
> >>
> > Any help here? I've spend several hours on this one. I'm not out of
> > ideas but I'm pretty challenged by this. Currently trying things with
> > System.Address_To_Access_Conversions.
> 
> Where is a problem?
> 
> with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays;
> procedure Double_Array_2 is
>     type Real_Vector_Access is access Real_Vector;
>     x_Ptr : Real_Vector_Access := new Real_Vector(-4 .. 3);
>     x : Real_Vector renames x_Ptr.all;
>     y : Real_Vector(0..7);
>     for y'Address use x'Address;
> begin
>     null;
> end Double_Array_2;
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Thanks, Dmitry. I kept trying to use a pointer for y. I anticipated that I would feel like an idiot when someone showed me how to do this and I was right.

Jerry


  reply	other threads:[~2017-11-26 10:31 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24 11:42 How to access an array using two different indexing schemes Jerry
2017-11-24 12:33 ` Jeffrey R. Carter
2017-11-24 15:52   ` AdaMagica
2017-11-24 22:25     ` Jerry
2017-11-25 13:57       ` AdaMagica
2017-11-24 22:23   ` Jerry
2017-11-25 15:39   ` Robin
2017-11-25 20:58     ` Jerry
2017-11-26 10:22       ` Robin
2017-11-28 21:57       ` G. B.
2017-11-24 17:37 ` A. Cervetti
2017-11-24 21:48   ` Jerry
2017-11-24 22:15     ` Robert A Duff
2017-11-24 23:38       ` Jerry
2017-11-26  1:07         ` Jerry
2017-11-26  8:58           ` Dmitry A. Kazakov
2017-11-26 10:31             ` Jerry [this message]
2017-11-28  1:31             ` Randy Brukardt
2017-11-28  1:25   ` Randy Brukardt
2017-11-29  4:57     ` Jerry
2017-11-29 15:01       ` AdaMagica
2017-11-29 15:21         ` AdaMagica
2017-11-30  5:32           ` Jerry
2017-11-30  5:30         ` Jerry
2017-11-29 15:03       ` AdaMagica
2017-11-29 20:53         ` Randy Brukardt
2017-11-29 16:03       ` Shark8
2017-11-29 17:04         ` AdaMagica
2017-11-29 20:56           ` Randy Brukardt
2017-11-30  5:56             ` Jerry
2017-11-30 11:11               ` AdaMagica
2017-11-30 11:40                 ` AdaMagica
2017-11-30 14:47                   ` Niklas Holsti
2017-11-30 17:30                     ` AdaMagica
2017-11-30 19:31                       ` G. B.
2017-11-30 19:43                         ` Shark8
2017-11-30 22:10                           ` Randy Brukardt
2017-11-30 21:57                     ` Randy Brukardt
2017-11-30 22:49                 ` Jerry
2017-11-30 23:00                   ` Jerry
2017-11-30 21:50               ` Randy Brukardt
2017-11-30 23:13                 ` Jerry
2017-11-24 18:37 ` Per Sandberg
2017-11-24 21:28   ` Jerry
2017-11-24 21:40     ` Dmitry A. Kazakov
2017-11-28  1:33     ` Randy Brukardt
2017-11-24 22:12 ` Robert A Duff
2017-11-28  1:39   ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox