develooper Front page | perl.perl5.porters | Postings from September 2016

Re: pounding the smartmatch drum

Thread Previous | Thread Next
September 8, 2016 01:18
Re: pounding the smartmatch drum
Message ID:
Aristotle Pagaltzis wrote:
>Without LHS overloading the given($@) API in autodie is unimplementable.

If it's regarded as an API, that was always a faulty one.  The matching
implemented by the suggested idiom has never actually been what it
purported to be, because matching rules other than autodie::exception's
~~ lhs overload would get involved anywhere that the exception was not
of that class.  We shouldn't be tied down by an erroneous use of an
experimental feature.

The API that actually works, $@->isa("autodie::exception") &&
$@->matches("open"), will remain.  A working smartmatch-based API,
of the form when(autodieish("open")), using objects that overload ~~
from the rhs, is readily achievable.

>We promoted that pragma to users as a good idea for years. We can't just
>renege on that.

You're overstating the case.  This wouldn't diminish the functionality
or usefulness of the autodie pragma.  It only affects the use of autodie
*in combination with given*.  Admittedly that's a use suggested by the
autodie documentation, but code doing it already incurs a "given is
experimental" warning.

>And to do so we would first have to add an alternative to autodie and to
>deprecate the given($@) API for some time.

We do not need an alternative to autodie.  We only need to change its
documentation to stop recommending the faulty use of given.  Probably also
change its ~~ lhs overload to warn that this facility is going away.
Optionally also implement rhs matcher objects in autodie and suggest
their use in the documentation.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About