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

Re: [perl #132788] Blead Breaks CPAN:LEMBARK/Object-Trampoline-1.42.tar.gz

Thread Previous | Thread Next
From:
Zefram
Date:
February 18, 2018 22:40
Subject:
Re: [perl #132788] Blead Breaks CPAN:LEMBARK/Object-Trampoline-1.42.tar.gz
Message ID:
20180218223955.v4adxa3llnqdgpth@fysh.org
demerphq wrote:
>To fix that without loading overload.pm I would have to more or less
>extract a nice chunk of the internals of overload.pm into Carp.

It would be reasonable to load overload.pm when a reference arg is seen,
in order to deal with that situation.  However, it doesn't need to load
overload.pm until that situation arises, and should not.  It shouldn't
impose the loading of overload.pm on programs that don't make stack
traces.  There's a general principle in Carp of being minimal in what
it loads, because of its unique role and its ubiquity.

>Some  of them appear to be related to back-compat, but some of them are
>just egregious reimplementation of another modules functionality for the
>purpose of avoiding that module:

No, they're not.  The downgrade example isn't about whether the utf8.pm
module is loaded, because that's not how utf8::downgrade() gets defined.
utf8::downgrade() is defined by the core, regardless of the utf8.pm
module, on any Perl from 5.7.1 onwards.  The alternate implementation
exists for compatibility to Perl 5.6, which is still a consideration
for CPAN releases (though we're now on the tail end of that era).
The circumspectness about looking for utf8::downgrade() is to avoid
vivifying the unwanted utf8:: stash on 5.6.

The optionality of utf8::is_utf8() is likewise for 5.6 compat.
The optionality of B::svref_2object() *is* to avoid a dependency, but
it's not reimplemented if not available: the extra information that
it would have supplied is just omitted from a rare diagnostic message.
The optionality of overload::StrVal() is, as you noted, predicated on
the incorrect assumption that overloading only happens with overload.pm
loaded: if that had been correct then it would mean that overload.pm
wasn't required unless it was already loaded, so a dependency was
avoidable.

>                                               I plan to just use
>overload.pm and break this expectation.

Don't just do that.  Be cautious; follow the precedent of minimising
module loading and avoiding stash vivification.  Carp is quite a subtle
module, in response to a unique set of constraints arising from its role
as the standard error-handling module.  Heavy-handed editing is likely
to do damage.

-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