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

Re: chained comparisons

Thread Previous | Thread Next
From:
Tomasz Konojacki
Date:
April 8, 2020 05:15
Subject:
Re: chained comparisons
Message ID:
20200408071506.CCE5.5C4F47F8@xenu.pl
On Sun, 5 Apr 2020 07:09:48 +0100
Zefram via perl5-porters <perl5-porters@perl.org> wrote:

> 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

This makes sense from the internals POV but it's a very surprising
behavior from the user's POV. The concept of magic doesn't exist on the
language level, it can't be used to explain the current behavior to the
users. All they see is that a tied variable is being evaluated twice.

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