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

Re: review of perlexperiment, 2021-10

Thread Previous | Thread Next
From:
Yuki Kimoto
Date:
October 14, 2021 03:41
Subject:
Re: review of perlexperiment, 2021-10
Message ID:
CAExogxPB5Z5RG7cKDnfRJyyaWTAB-WapkafukEhauKiQ-tOFDg@mail.gmail.com
2021-10-4 6:50 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote:

> On Sun, 03 Oct 2021 16:41:37 -0400
> "Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:
> > *isa* — I believe isa is complete.  It works, it can be used, no
> > design changes seem to be in the wings.  What prevents us from
> > calling this stable (and including it in the v5.36.0 feature bundle)?
> > #18754 <https://github.com/Perl/perl5/issues/18754>
>
> Largely just waiting on it to timeout really.
>
> There's still *an* ongoing problem in that it works kinda weirdly with
> the underlying reftype of an object.
>
> By which I mean, I had *wanted* the operator to work such that
>
>     $obj isa Some::Class  =>  implies "Some::Class" is somewhere in the
>                               @ISA tree for $obj
>
> But this isn't actually true for the special stringy names of the
> reftype; e.g. any blessed hash reference happens to be true for
>
>     $obj isa HASH
>
> and yet the @ISA tree does not contain qw(HASH), nor does
>
>     $obj->meth(...)
>
> attempt to invoke sub HASH::meth {}.
>
> It's a bit of a thorn in the design. It's discussed more in
>
>   https://github.com/Perl/perl5/issues/18531
>
> but we never really reached a conclusion.
>
>
 Is it possible to change to the expected behavior?

  # Syntax
  $obj isa Foo

  # Logic (Although it has to be written in C)
  my $ok;
  if (Scalar::Util::blessed $obj) {
    my $class = ref $obj;
    my $isa_classes = mro::get_linear_isa($class);
    for my $isa_class (@$isa_classes) {
      if ($isa_class eq 'Foo') {
        $ok = 1;
        last;
      }
    }
  }

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