develooper Front page | perl.perl5.porters | Postings from August 2008

Re: unless(...) terser than if(!...)

Thread Previous | Thread Next
From:
Yitzchak Scott-Thoennes
Date:
August 28, 2008 16:29
Subject:
Re: unless(...) terser than if(!...)
Message ID:
38026.97.113.85.232.1219966184.squirrel@webmail.efn.org
On Thu, August 28, 2008 2:45 pm, Nicholas Clark wrote:
> If I write this:
>
> $ ./perl -Ilib -MO=Concise -e 'print if !$a'

> it uses one more op than the semantically equivalent:
>
> $ ./perl -Ilib -MO=Concise -e 'print unless $a'

> Couldn't we optimise the former to the latter fairly easily?

In void context, yes.  (I wouldn't worry about the ! vs. bool
overload difference.)



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