develooper Front page | perl.perl5.porters | Postings from August 2010

Re: [PATCH] Re: [perl #76814] FETCH called twice.

Thread Previous | Thread Next
From:
Abigail
Date:
August 19, 2010 08:07
Subject:
Re: [PATCH] Re: [perl #76814] FETCH called twice.
Message ID:
20100819150907.GD22963@almanda
On Sun, Aug 01, 2010 at 12:14:52PM -0700, Father Chrysostomos wrote:


Thank you for your patches.


> • The first patch fixes string comparison operators. It changes sv_eq, sv_cmp, sv_cmp_locale and sv_collxfrm to _flags forms, with macros under the old names for sv_eq and sv_collxfrm, but functions for sv_cmp* since pp_sort.c needs them.
> 
> • The second patch fixes ! by doing the same thing to sv_2bool and adding SvTRUE_nomg. It also corrects the docs that state incorrectly that SvTRUE does not handle magic.
> 
> • The third patch fixes m and s. It modifies pp_regcomp to avoid extra magic. It also corrects a bug in sv_catsv_flags, which would still call mg_get(ssv) even without the SV_GMAGIC flag set.
> 
> • The fourth patch fixes y. (This has caused double magick at least as far back as 5.6.2.)
> 
> • The || case is not a bug, as there are two separate operators operating on it in the test script. In
> 
>   $dummy = $x || $y
> 
> The || does mg_get($x). If it’s true it returns it and the = does mg_get($x). If $x is false, then $y is returned, so magic is called once on each of $x and $y. Similarly, && will seemingly call mg_get($x) twice if $x is false.
> 
> If you just write:
> 
>   $x || $y
> 
> then magic is only called once on $x.

I don't understand why it's not a bug. If I do

    $dummy = f () || g ();

people would consider it to be a bug if f () were to be called twice. Why
should $x be FETCHed twice then? In fact, IMO, if $x is tied, $x in
rvalue context should just be a shorthand for C<< (tied $x) -> FETCH >>.


> The fifth patch attached hereto corrects the test.
> 
> • The sixth attachment is not a patch, but a text file of entries to be copied and pasted into perldelta, patches for which go stale too quickly.
> 
> Let’s see whether I remember the attachments....
> 



Abigail

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