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

Re: chained comparisons

Thread Previous | Thread Next
From:
Zefram via perl5-porters
Date:
April 5, 2020 06:09
Subject:
Re: chained comparisons
Message ID:
20200405060948.kpkwwgpkfb6tn6ol@fysh.org
Sawyer X wrote:
>Zefram, can you take a look, please? I am in agreement that a single FETCH is
>a reasonable user expectation.

We discussed this very issue earlier.  The expression is evaluated to an
SV only once, under control of the chaining mechanism.  But get magic
happens twice, because that's performed by the comparison operation
itself.  A tied fetch operation is part of get magic, not evaluation.
Perl's interleaving of lvalue and rvalue aspects of scalars, in particular
the way get magic mutates the scalar in place rather than returning a
separate value, prevents us from separating the get magic from the rest
of the comparison op.

-zefram

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