From: Sam Roberts Date: 2003-06-05T09:47:01+09:00 Subject: Re: case of sub! not working Somebody suggested that strings returned by ENV#[] be frozen, emphasizing that they can't be changed. I like that idea, it seems to get rid of any need to add an explanation of all this to the FAQ. Sam > I'll take a stab at it. I can't promise that > what I say is correct. > > The illusion of ENV being a simple hash is a > good one. But remember that when you get/set > environment variables, ultimately you are > calling getenv/setenv or some equivalent. > > It's one thing to do an ENV[x] = y, as []= > is a method invoked on ENV. We can trap the > change and call setenv. > > But if ENV[x] refers to a string, and I change > that string... then ENV itself hasn't changed. > In fact, for an in-place change, even the > object id of the string hasn't changed. > > To accomplish something like ENV[x].sub! working > intuitively, we would have to monitor every > string object referenced by ENV and watch to see > when any of them was changed. > > Perhaps possible but impractical and inefficient. > > Hal > >