comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Modes (was unbounded_string)
Date: Mon, 13 Oct 2003 11:28:48 +0200
Date: 2003-10-13T11:28:48+02:00	[thread overview]
Message-ID: <hlrkovgfspku7epl2j5586g1ut6ih5os41@4ax.com> (raw)
In-Reply-To: x7v4qygi6qw.fsf@smaug.pushface.org

On 11 Oct 2003 08:16:39 +0100, Simon Wright <simon@pushface.org>
wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> writes:
>
>> declare  -- I need the value of QUERY_STRING here
>>    Temp : String renames Getenv ("QUERY_STRING").all;
>>       -- Temp is an alias to the env-string. You cannot modify it.
>>       -- Yet it is not a pointer. An analogue would be C++ reference
>> begin
>>    ... -- Doing with Temp everything I can to do to
>>        -- a constant String
>> end; -- I don't need it anymore
>
>Actually you *can* modify it:
>
>   with Ada.Text_IO; use Ada.Text_IO;
>   with GNAT.OS_Lib; use GNAT.OS_Lib;
>
>   procedure Env is
>      Temp : String renames Getenv ("COLDFRAME").all;
>   begin
>      Temp (1) := 'x';
>      Put_Line (Temp);
>   end Env;
>
>then
>
>   smaug.pushface.org[5]$ COLDFRAME=foo ./env
>   xoo
>
>(GNAT 3.16a1)
>
>Should GNAT.OS_Lib.Getenv have been defined as returning a constant
>string access?
>
>   type Constant_String_Access is access constant String;

No, if Jeffrey Carter (see his post) is right and the result is
presently allocated on the heap, then it is a very bad design.

Clearly Getenv should either return an Unbounded_String or a plain
String.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2003-10-13  9:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20031010074015.761204C40C1@lovelace.ada-france.org>
2003-10-10  8:27 ` Modes (was unbounded_string) Andrew Carroll
2003-10-10  9:15   ` Dmitry A. Kazakov
2003-10-11  7:16     ` Simon Wright
2003-10-13  9:28       ` Dmitry A. Kazakov [this message]
2003-10-10 15:18   ` Stephen Leake
2003-10-10 16:21     ` Martin Dowie
2003-10-14 18:47     ` Craig Carey
2003-10-10 19:06   ` Jeffrey Carter
2003-10-13  9:33     ` Dmitry A. Kazakov
2003-10-13  9:40       ` Stephane Richard
2003-10-13 10:12         ` Dmitry A. Kazakov
2003-10-15  2:16         ` Warren W. Gay VE3WWG
2003-10-15  3:36           ` Jeff C,
2003-10-16 16:45             ` Warren W. Gay VE3WWG
     [not found] <20031010094017.680474C40C1@lovelace.ada-france.org>
2003-10-10 10:58 ` Andrew Carroll
replies disabled

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