develooper Front page | perl.perl5.porters | Postings from June 2021

Re: PSC #024 2021-06-11

Thread Previous
Dan Book
June 14, 2021 05:57
Re: PSC #024 2021-06-11
Message ID:
On Mon, Jun 14, 2021 at 12:09 AM mah.kitteh via perl5-porters <> wrote:

> b. dealing with the fact that what's being checked is not a reference and
> therefore has no access to UNIVERSAL::isa?

Not a blessed reference, specifically. It does also work on non-references,
since those are class names.

I just happened to find this when doing some "fact checking"; does this
> infix "isa" address the shortcomings of UNIVERSAL::isa?

Yes. It calls isa on the blessed reference, but doesn't throw an exception
when called on an unblessed reference or undef, thus replacing the common
(but not well known) idiom to do this correctly: `defined(blessed $thing)
&& $thing->isa($class)`


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