But how would you then copy, without having to bring the reference in
existance first.  How would you copy period?  Maybe I am not understanding,
hopefully someone can clear it up:)

Ilya

-----Original Message-----
From: David L. Nicol
To: Mark J. Reed
Cc: '[EMAIL PROTECTED] '
Sent: 07/20/2001 1:38 PM
Subject: aliasing a value in a while each loop

"Mark J. Reed" wrote:
> 
> Well, other than the fact that the while(each) doesn't do aliasing.
> Since that would be the whole point, ignore that last message.
> 
> On Fri, Jul 20, 2001 at 01:21:57PM -0400, Mark J. Reed wrote:
> > On Fri, Jul 20, 2001 at 11:17:13AM -0600, Sterin, Ilya wrote:
> > > But this will be flattened, so I would think
> > >
> > > for my($key, $val)(%my_hash)
> > > { ... }
> > >
> > > Would be a great convenience.  $key and $val being aliased
accordingly.
> > I'm sorry, but I fail to see how this is a big improvement over the
> > current version:
> >
> >     while (my ($key, $val) = each %my_hash)
> >     { ... }


         while (my ($key, $$val) = each %my_hash)
             { ... }

and have $val be a reference to the value -- that would be cool,
almost as cool as magic to make $val an alias.  I think the current
behavior is to autoviv ("$val"eq'SCALAR(0x80f5934)') and copy the
value there.

What I am suggesting is:

(drumroll please) 

  Assignment to a nonexistent reference becomes an
  alias instead of a copy.

It's ugly with current implementations, but with a fully introspective
rewriting interpreter, (i.e. an optimization pass) it could happen?




-- 
                                           David Nicol 816.235.1187
                       "Mary had a little chainsaw" -- Angus Oblong

Reply via email to