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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-16 00:37:27 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Counter-proposal for variable arrays Date: Thu, 16 Oct 2003 09:38:03 +0200 Message-ID: <7aisov0u9cha33e1fgvpli7mmdqqmmh7l9@4ax.com> References: <1065215180.95094@master.nyc.kbcfp.com> <19p2ovk1jh4krn2h5cql44p37ovf6va99i@4ax.com> <4pe7ov0gsepk8p8cq88ropvq4sookdhatk@4ax.com> <1065635640.270857@master.nyc.kbcfp.com> <725aovsqh10dv5p5nh1e7k2qvjjcqustsa@4ax.com> <1065709998.992831@master.nyc.kbcfp.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1066289845 25286196 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:949 Date: 2003-10-16T09:38:03+02:00 List-Id: On Wed, 15 Oct 2003 19:52:22 -0500, "Randy Brukardt" wrote: >"Hyman Rosen" wrote in message >news:1065709998.992831@master.nyc.kbcfp.com... >> Dmitry A. Kazakov wrote: >> > It is already so. Consider: >> > type Tricky (I, J : Positive) is record >> > X : String (1..I); >> > Y : String (1..J); >> > end record; >> > The offset to Y is variable and depends on the value of I. >> >> I Didn't Know You Could Do That In Ada(tm). :-) >> It really works that way? And you can have procedures >> which just take unconstrained Tricky parameters, and >> they'll know how to deal with all instances? Cool! > >You can write this, but it often isn't implemented with variable offsets. >What Janus/Ada does is to use discontinous storage for >depends-on-discriminant components. The component itself is a descriptor, >and has fixed size. The array data is allocated separately. That way, we can >actually change the data memory when the discriminants are changed by >assignment, and we don't use more memory than necessary. An interesting approach. But what will happen if I write: type Tricky_Ptr is access Tricky; for Tricky_Ptr'Storage_Pool use My_Stack_Pool; Do you switch between representations? --- As I see, your compiler is ready for: type Crazy (T : Tag) is record Anything : Root_Type'Class (T); end record; (:-)) --- Regards, Dmitry Kazakov www.dmitry-kazakov.de