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,13b19740d69cbdc2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-13 02:28:32 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Modes (was unbounded_string) Date: Mon, 13 Oct 2003 11:28:48 +0200 Message-ID: References: <20031010074015.761204C40C1@lovelace.ada-france.org> 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 1066037310 22085138 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:767 Date: 2003-10-13T11:28:48+02:00 List-Id: On 11 Oct 2003 08:16:39 +0100, Simon Wright wrote: >Dmitry A. Kazakov 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