Hello aristotle, hello all,

no good to hide away... *sigh*

>From the keyboard of A. Pagaltzis [10.12.07,13:41]:

> * shmem <[EMAIL PROTECTED]> [2007-12-10 12:55]:
> > Well, if we were to return an array reference instead of a hash
> > ref,
> > 
> > sub [EMAIL PROTECTED],shift}
> > 
> > works. Why does the shift get executed before an array
> > reference is constructed - but not if a hashref is constructed
> > - from an array?
> 
> It probably doesn't. Either way, evaluation order is a red
> herring: your construction will work regardless of which
> subexpression is evaluated first!
> 
> You managed to confuse yourself. Congratulations. :-)  (Or you
> are underhandedly trying to confuse us. In that case, sorry bub,
> better luck next time. :-) )

Thank you ;-)

Had I tried to confuse you, I had added a smiley at the end, but
that has not been the case. See, that's my way to write bugs:
in gnawing on a solution, forgetting completely things that are
obvious to me in other circumstances.

Had somebody else posted that, I would have responded likewise,
but as every time, one is blind to his own bugs ;-)

0--gg-

> What happens is that `\` takes a *reference* to the array. And
> of course when you do that, any modifications of the referent,
> including *subsequent* modifications, will be seen by anyone who
> holds a reference to it.
> 
> In contrast, the hash constructors make a *copy* of the array,
> and that copy will not be affected but subsequent modifications
> to the source array.
> 
> Anyone who has trouble following should consider the difference
> between the following two:
> 
>     sub new { bless [EMAIL PROTECTED], shift }
>     # vs
>     sub new { bless [EMAIL PROTECTED], shift }
> 
> Consider how many arrays are involved in either case, and which
> one is affected by the `shift`.
> 
> 

-- 
_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s,/,($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e,e && print}

Reply via email to