ambrus has asked for the wisdom of the Perl Monks concerning the following question:
When you do a list assignment,
perl tries to do it efficently.
Perl_newASSIGNOP in op.c checks if it can
do
({@a=@b;push@a,@c;}
instead
of) @a=(@b,@c); in a faster way
This is usually possible, bot not in cases like ($a,$b)=($b,$a);
or @a=(@b,@a);.
However, there is a bug(?) in Perl concerning this, when you type {*a=*b;@b=(1,2);@b=@a;$,=" ";print @a;}, it prints two undef's instead of 1 and 2. Is this a bug or a "feature", that is, is it intentional?
UPDATE My description of the optimization is wrong, as ysth said correctly. I don't actually know how this optimiztion works really.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: *a=*b;@a=@b problem
by tilly (Archbishop) on Nov 02, 2003 at 16:47 UTC | |
|
Re: *a=*b;@a=@b problem
by Anonymous Monk on Nov 02, 2003 at 16:36 UTC | |
|
Re: *a=*b;@a=@b problem
by ysth (Canon) on Nov 02, 2003 at 19:26 UTC | |
|
Re: *a=*b;@a=@b problem
by Roger (Parson) on Nov 02, 2003 at 23:32 UTC | |
|
Re: *a=*b;@a=@b problem
by rir (Vicar) on Nov 03, 2003 at 17:13 UTC |