develooper Front page | perl.perl5.porters | Postings from February 2018

[perl #132902] Blead Breaks CPAN: Class::Std

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
February 27, 2018 17:12
Subject:
[perl #132902] Blead Breaks CPAN: Class::Std
Message ID:
rt-4.0.24-6261-1519751543-601.132902-15-0@perl.org
On Mon, 26 Feb 2018 23:23:40 -0800, demerphq wrote:
> On 26 February 2018 at 08:50, Father Chrysostomos via RT
> <perlbug-followup@perl.org> wrote:
> > On Sun, 25 Feb 2018 20:28:02 -0800, demerphq wrote:
> >> On 26 February 2018 at 05:02, Father Chrysostomos via RT
> >> <perlbug-followup@perl.org> wrote:
> >> > On Sun, 25 Feb 2018 16:14:44 -0800, demerphq wrote:
> > Bug #132910, which was erroneously merged into this ticket, would
> > have happened, but we would not have noticed, because it would only
> > have happened with a new Carp on perl 5.14 or earlier.
> 
> I dont follow. If we simply did
> 
> use overload ();
> 
> then we could replace this logic:
> 
> # overload uses the presence of a special
> # "method" named "((" or "()" to signal
> # it is in effect.  This test seeks to see if it has been set up.
> if (_mycan($pack, "((") || _mycan($pack, "()")) {
>     # Argument is blessed into a class with overloading, and
>     # so might have an overloaded stringification.  We don't
>     # want to risk getting the overloaded stringification,
>     # so we need to use overload::StrVal() below.  But it's
>     # possible that the overload module hasn't been loaded:
>     # overload methods can be installed without it.  So load
>     # the module here.  The bareword form of require is here
>     # eschewed to avoid this compile-time effect of vivifying
>     # the target module's stash.
>     require "overload.pm";
> }
> my $sub = _fetch_sub(overload => 'StrVal');
> return $sub ? &$sub($arg) : "$arg";
> 
> with a simple:
> 
> return overload::StrVal($arg);

You’re right.

> > Alternatively, for perl 5.10.1 to 5.14, we can copy the more recent
> > overload::StrVal into Carp.  It consists of: sub { no overloading;
> > "$_[0]" }.  You can’t get much faster than that.  In which case we
> > might as well use it also in current blead and avoid extra
> > conditions.  We don’t need to load overload.pm at all in perl
> > 5.10.1+.
> 
> Doesnt this also suffer the problem you mentioned of loading code at
> run time?

Not if we load overloading.pm up front, which my patch does.  I think it’s unavoidable.

> > For Perl 5.8.0 (yes, I think we should support 5.8.0 still),
> > overload::StrVal has the worst implementation yet.  It
> > unconditionally blesses any ref passed to it, which may well cause
> > real problems.  Use of overload::StrVal isn’t all that common,
> > compared to Carp.  Carp will make it common and start blessing
> > people’s references left and right when generating a stack trace.
> > Avoid this old StrVal at all costs!
> 
> Would some of this be solved by moving overload.pm to dist and
> allowing it to be released on cpan like Carp is?

Please, no.  That would be a nightmare.  We would end up playing this same compatibility game with overload.pm.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: resolved
https://rt.perl.org/Ticket/Display.html?id=132902

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