develooper Front page | perl.perl5.porters | Postings from April 2020

Re: chained comparisons

Thread Previous | Thread Next
From:
David Nicol
Date:
April 9, 2020 15:07
Subject:
Re: chained comparisons
Message ID:
CAFwScO-evR1OoKg34nQrAng13OiGu1333WXo_MrZ8VOVj7ZfJw@mail.gmail.com
if middleval is a function, does it get called twice or is the result
cached?

if ($lower <= ( sub {$tiedthing})->() <= $upper ) { # a monad with a gonad

On Thu, Apr 9, 2020 at 6:17 AM Sawyer X <xsawyerx@gmail.com> wrote:

> Honestly, I think this is the best compromise.
>
>
>
> On 4/8/20 7:11 PM, David Nicol wrote:
> >
> >
> > so document this and recommend making local copies of the fetched
> > values from expensive tied variables, at least for now
> >
> >
> > my $middleval = $tiedthing;
> > if ($lowerbound < $middleval < $upperval) { ...
> >
> >
> >     . All users see is that a tied variable is being evaluated twice.
> >
> >
> >
> > --
> > "I know Darth Vader's really got you annoyed
> >  but remember if you kill him then you'll be unemployed" -- Alfred M.
> > Yankovic
>


-- 
"I know Darth Vader's really got you annoyed
 but remember if you kill him then you'll be unemployed" -- Alfred M.
Yankovic

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