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

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

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
September 29, 2011 07:39
Subject:
Re: [perl #100364] exit doesn't match its documentation
Message ID:
20110929163902.4c08c43c@pc09.procura.nl
On Thu, 29 Sep 2011 08:25:39 -0600, Tom Christiansen <tchrist@perl.com>
wrote:

> 
> 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;

If I read this I read it as '(   print (3 + 5)     ) * 8;'
unambiguously

>     return (3+5)*8;

useless use of '*8' in statement at line ...

> Those aren't anything like the same.

-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using 5.00307 through 5.14 and porting perl5.15.x on HP-UX 10.20, 11.00,
11.11, 11.23 and 11.31, OpenSuSE 10.1, 11.0 .. 11.4 and AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/

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