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

Re: Blessed objects are `isa` their reftype

Thread Previous | Thread Next
From:
David Christensen
Date:
February 16, 2021 22:57
Subject:
Re: Blessed objects are `isa` their reftype
Message ID:
06e74c1f-9161-5654-b20a-5b899c748517@holgerdanske.com
On 2021-02-16 14:19, Paul "LeoNerd" Evans wrote:
> On Tue, 16 Feb 2021 14:05:16 -0800 David Christensen wrote:
>> On 2021-02-16 13:17, Dan Book wrote:
>>> On Tue, Feb 16, 2021 at 4:14 PM David Christensen wrote:
>>>> On 2021-02-16 04:09, Paul "LeoNerd" Evans wrote:
>>>>> There is an odd asymmetry with isa when testing if an object is
>>>>> derived from its reference type:

>    $ perl5.32.1
>    use feature 'say';
>    use experimental 'isa';
> 
>    my $aref = [ 1, 2, 3 ];
>    say "1.TRUE" if $aref isa ARRAY;
> 
>    my $aobj = bless [ 5, 6, 7 ], "MyArray::Class";
>    say "2.TRUE" if $aobj isa MyArray::Class;
>    say "3.TRUE" if $aobj isa ARRAY;
>    ^D
>    2.TRUE
>    3.TRUE
> 
> The one numbered 3 is surprising.

Where is the specification for 'isa'?  I do not see 'isa' in the 
documentation for 'experimental':

     https://perldoc.perl.org/experimental


David

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