RE: aliasing a value in a while each loop

2001-07-23 Thread Sterin, Ilya

alias(%foo, %bar) is better IMO since it conforms to other functions in
perl.
my %foo is alias = %bar;  #seems a little out of scope of the language,
unless more functionality is implemented in that way.

Ilya

-Original Message-
From: Davíð Helgason
To: [EMAIL PROTECTED]; John Porter
Sent: 7/20/01 2:25 PM
Subject: Sv: aliasing a value in a while each loop

John Porter wrote:
> Perhaps a simple
> 
> alias( %foo, %bar );
> 
> for those times when you really just need a simple WTDI!

Would 

 alias %foo = %bar;

not be ok, 'alias' acting and binding like 'my' of course. Or 

 my %foo is alias = %bar;


No?


/davíð



Re: aliasing a value in a while each loop

2001-07-20 Thread Eric Roode

David L. Nicol wrote:
>
>Are there really situations where
>
>   $$reference = An Expression;
>
>is clearer than
>
>   $reference = \(An Expression);
>
>?

Eric is confused. I don't know about in Perl 6-to-be, but in Perl 5
those two mean totally different things:

   $foo  = \$bar; # sets $foo to be a ref to $bar
   $$foo = "hi mom";  # sets $bar to "hi mom"
   $foo  = \"hi mom"; # sets $foo to be a ref to "hi mom"
   
 --
 Eric J. Roode[EMAIL PROTECTED]
 Senior Software Engineer, Myxa Corporation




Re: aliasing a value in a while each loop

2001-07-20 Thread John Porter

David L. Nicol wrote:
>   Assignment to a nonexistent reference becomes an
>   alias instead of a copy.

Uh, I dunno.  Like Python/Ruby, but without the consistency.

I think special constructs -- defined as NOT doing assignment
-- should be allowed to set up aliases.  This includes, e.g. for().
Perhaps a simple

alias( %foo, %bar );

for those times when you really just need a simple WTDI!

Multiple aliases in one swoop:

alias
%foo => %bar,
@p => @Some::Other::Long::Class::Name::ISA,
$x => $db{tbl}{col}[r],
$y => substr( $s, 10, 15 ),
@z => @a[5..8,13];

etc.

-- 
John Porter




RE: aliasing a value in a while each loop

2001-07-20 Thread Sterin, Ilya

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