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

Re: [perl #53550] Overload and fallback binary or (|)

Thread Previous
From:
David Nicol
Date:
April 30, 2008 13:54
Subject:
Re: [perl #53550] Overload and fallback binary or (|)
Message ID:
934f64a20804301354n6d0169fan75ba5907570045be@mail.gmail.com
On Wed, Apr 30, 2008 at 11:01 AM, Rafael Garcia-Suarez
<rgarciasuarez@gmail.com> wrote:

>  Well, binary logical operators work on strings and on numbers. Which
>  is a source of problems in perl. (and also why one should really not
>  rely on fallback for those) I suggest a little note in overload.pm to
>  document the state with overload and logical ops as a potential
>  gotcha, but I don't think we can do better.


What if the part that forces the result of overload '""' to be a
string got struck?  There is nothing in the fallback code aside from
the convention of "" tending to be a string that indicates that
$_[0]->{n} should be a string, therefore overload must be doing the
conversion instead of making an accurate copy and letting the user of
the result convert it to a string if required.

Another possibility, heavier than identifying and deleting one line of code,
would be to create a bit-vector mode of expression besides string and number and
allow overload to directly allow access to "as-a-BV" perhaps with a '0|'
overload key, which would be defined to fallback to either '""' or '0+' instead
of punting to documenting a here-be-dragons warning.  Although without
complete refactoring of everything to support this new mode, currently
done with a heuristic (has PVOK flag? string : number (float or
integer)) AIUI that might become a lot of work

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