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 23:10
Subject:
Re: Blessed objects are `isa` their reftype
Message ID:
09b7c0d8-7f16-a0c3-57ba-526eb6e79044@holgerdanske.com
On 2021-02-16 14:57, David Christensen wrote:
> 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

'isa' is now a feature:

https://perldoc.perl.org/feature#The-'isa'-feature


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