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-Thread: 103376,dc1fff2721602dfa X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.75.71 with SMTP id a7mr609827paw.47.1359562154160; Wed, 30 Jan 2013 08:09:14 -0800 (PST) X-Received: by 10.50.236.40 with SMTP id ur8mr752938igc.6.1359562153969; Wed, 30 Jan 2013 08:09:13 -0800 (PST) Path: 6ni25163pbd.1!nntp.google.com!ld4no4875582pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 30 Jan 2013 08:09:13 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <4978d638-a04b-4561-85e9-cf6620265af2@googlegroups.com> <86boc63n5d.fsf@gaheris.avalon.lan> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada and string literals From: Adam Beneschan Injection-Date: Wed, 30 Jan 2013 16:09:14 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-01-30T08:09:13-08:00 List-Id: On Wednesday, January 30, 2013 5:52:58 AM UTC-8, Niklas Holsti wrote: > > More importantly, I cannot see why you would want an access to a string > > literal. >=20 > > Just use the string literal as a normal parameter, and let the compiler > > worry about how to handle that. >=20 > I don't know why the OP wants an access, but I can image a situation > where one needs, for example, to call a subprogram with several string > parameters, which should have different values depending on different > logical conditions, in various combinations. It is then easier to > represent each parameter by local variable that can be assigned > different values in different if-then-else statements, and then use the > local variables as actual parameters in the call.... Another fairly common use case is a constant array whose values are string = literals. =20 By the way, if you use an "access constant string" type, I believe that com= pilers should, if possible, work things out so that if the type of new string' ("Literal") is an access-constant-string, the compiler will generate a "literal" pointe= r that points to constant data loaded together with the code, so that the N= EW won't cause any allocation or any other code to be run at runtime. This= isn't a requirement, but it's recommended. That would result in something= equivalent to the situation in C, without any unnecessary overhead. You'd= have to make sure you don't try to convert this access type to an access-[= not-constant]-string type, though; that isn't allowed for obvious reasons. -- Adam