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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2afac1a4161c7f35 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Two simple language questions Date: 1998/01/07 Message-ID: #1/1 X-Deja-AN: 313624417 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <68uq34$7tk@tomquartz.niestu.com> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-01-07T00:00:00+00:00 List-Id: Chip Richards (chipr@niestu.com) wrote: : I hope. : First: It says in the Intro to Ada 9X, in Chapter 2, "General access types can : also be used to program static ragged arrays as for example a table of : messages of different lengths." Now, I know this has been asked before, some : time ago, but I cannot seem to locate the text of the exchange. What I want : to know is, exactly what is the syntax for doing this? I've so far used : allocators, i.e.: : strs: StringArr := : ( : new string'("Line 1"), : new string'("Line 2"), : ... : new string'("Line the Last") : ); : Which works great, but isn't exactly the "static" ragged arrays mentioned in : the intro. Actually, this should work as desired if StringArr is defined as an array of access-to-constant String. E.g.: type String_Constant_Ptr is access constant String; type StringArr is array(Positive range <>) of String_Constant_Ptr; The implementation advice in the RM (13.11(24)) suggesting that access-to-constant types need not support deallocation is meant to encourage implementations to implement allocators for access-to-constant types statically (presuming the initializing value is compile-time known). In other words, new String'("Line 1") should allocate and initialize the space at link-time, and at run-time deliver the address of this link-time allocated and initialized space. This is essentially identical to the implementation of string literals in C/C++. For what it is worth, the Ada 95 compilers based on our AdaMagic front end (i.e. Aonix ObjectAda 7.* and Green Hills AdaMulti 95) follow this implementation model. I'm not sure about GNAT, OCSystems, Rational, etc. : ... : Chip -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA