comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Modes (was unbounded_string)
Date: 11 Oct 2003 08:16:39 +0100
Date: 2003-10-11T08:16:39+01:00	[thread overview]
Message-ID: <x7v4qygi6qw.fsf@smaug.pushface.org> (raw)
In-Reply-To: htqcov8rj5v1ii4aiad48sso0dhj0glcan@4ax.com

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;




  reply	other threads:[~2003-10-11  7:16 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 [this message]
2003-10-13  9:28       ` Dmitry A. Kazakov
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