develooper Front page | perl.perl5.porters | Postings from September 2011

Re: [perl #100364] exit doesn't match its documentation

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
September 29, 2011 07:25
Subject:
Re: [perl #100364] exit doesn't match its documentation
Message ID:
24924.1317306339@chthon

Zefram <zefram@fysh.org> wrote
   on Thu, 29 Sep 2011 14:50:58 BST: 

> Nicholas Clark wrote:
>> And C<1 == 1> is an expression? Right?

>>  $ perl -wle 'exit 1 == 1'; echo $?

> 1 == 1 certainly is an expression, but this parses as exit(1) == 1, so
> your code doesn't actually contain 1 == 1 as a subexpression.  This is
> perfectly consistent behaviour: unary functions (with unparenthesised
> argument lists) bind tighter than infix comparison ops.  It's documented
> in perlop.  You can see the same effect here:
 
>   $ perl -wle 'print int 10.5 == 10'    
>   1

Yup, that's the same example as I was about to provide.

Another related example where things aren't what you might think
they are is this:

    print  (3+5)*8;
    return (3+5)*8;

Those aren't anything like the same.

--tom

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