develooper Front page | perl.perl6.language | Postings from June 2001

Re: suggested properties of operator results

Thread Previous
From:
Graham Barr
Date:
June 11, 2001 05:50
Subject:
Re: suggested properties of operator results
Message ID:
20010611134823.C50444@pobox.com
On Mon, Jun 11, 2001 at 01:42:53PM +0100, Simon Cozens wrote:
> On Mon, Jun 11, 2001 at 01:31:36PM +0100, Graham Barr wrote:
> > On Mon, Jun 11, 2001 at 01:34:49AM -0700, Chris Hostetter wrote:
> > >    $input = 4;
> > >    $bool = $input < 22;        # $bool = 1 is valueR(22)
> > >    print "ok!" if $bool == 1;  # whoops, '==' is looking at $bool.valueR
> > 
> > Well perhaps   $input < 22   should yield  22 is true
> 
> Or perhaps you should have said "my bit $bool;" :)

Um, perhaps I was no clear. I meant $bool to get 22, which now
I read goes against the previous message :)

But if  < returns RHS is true when the LHS is less than the RHS
you can do

  6 < $var < 10

as long as precedence means that is

 (6 < $var) < 10

and perl uses the truth to determine when to stop as this would expand to

  (6 < $var) and ($var < 10)

And of course if it actually returned LHS is false when the LHS is
greater, then   $c = max($a,$b) is simply   $c = $a < $b

Graham.

Thread Previous


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