[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [Fun With Perl] Re: How to swap $p and $q without $tmp



On Fri, Jun 11, 1999 at 05:22:19PM +0300, Ariel Scolnicov wrote:
> Roland Giersig <Roland.Giersig@alcatel.at> writes:
> 
> > Bek Oberin wrote:
> > >
> > > That makes sense but can somebody explain how
> > > 
> > > > At 10:16 PM 6/10/99 -0500, Tushar Samant wrote:
> > > > >    $q^=$p^=$q^=$p
> > > 
> > > is  parsed?
> > 
> > Easy. Just right to left. Equivalent multiline version:
> > 
> >  $q ^= $p;
> >  $p ^= $q;
> >  $q ^= $p;
> 
> Now, if it were C, say, then this version would be OK, but the first
> version would be undefined.  Are we really promised the equivalence of 
> the 2 versions in Perl?
> 

Would that really be undefined in C?  The RHS of an assignment has to be
evaluated before the assignment is performed.

Ronald

==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org