develooper Front page | perl.perl5.porters | Postings from July 2010

RE: Order of evaluation of terms (was peephole optimiser could prune more dead code)

Thread Previous | Thread Next
From:
Jan Dubois
Date:
July 15, 2010 14:50
Subject:
RE: Order of evaluation of terms (was peephole optimiser could prune more dead code)
Message ID:
021d01cb2467$ac2b2050$048160f0$@activestate.com
On Thu, 15 Jul 2010, Jan Dubois wrote:
> Once you implement magic/overloads that violate the underlying algebraic
> relationships in your overloaded operators you will end up in a world
> of pain.  E.g. the following expressions should always be true:
> 
>     ($a + $b) == ($b + $a)
>     ($a < $b) == ($b <= $a)
>     "$a" eq $a
>     ($a eq $b) && ($b eq $c) == ($a eq $c)

It just occurred to me (to continue the "close the circle" meme):

      ($a.$a) eq ($a x 2)

which ties this back to the rule that FETCH magic needs to be side-effect
free as well.  How does it make sense that the left side should call FETCH
magic twice when the right side can get away with calling it only once?

Cheers,
-Jan



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About