Mailing List Archive

isa (Re: "Line Noise" considered offensive)
>From: Tom Christiansen <tchrist@alumni.cs.colorado.edu>

>Do you think there should be a UNIVERSAL::isa() function
>so that $obj->isa("thngiehtingie") would quickly and efficiently
>report whether $obj was derived from class "thingie"?

I've always resisted marches through @ISA, hoping we'd come up with
something faster or that if would never have to be done at all, but I guess
that fell apart when I said that "an object is an object is an object" is
sometimes insufficient in Perl.

I think we'd have to start at the beginning and fix sv_isa(). Then make
sv_isa() available as UNIVERSAL::isa(). I guess it's a march through
@ISA...ug.

I cringe when I think of all the calls to isa() that people will put in
their code. They'll probably even use it on $self, of all things. Oh yes,
load those modules up with isa() calls, unnecessary in most situations, then
wonder why the app is so slow. It is times like these when I wish Perl
supported pre/post -conditions with a compile-time switch to control them.

But, grinch that I am, I recognize that there are times when you do need to
know the implementation and ancestry of the object.

Dean
Re: isa (Re: "Line Noise" considered offensive) [ In reply to ]
Dean Roehrich writes:
>
> >From: Tom Christiansen <tchrist@alumni.cs.colorado.edu>
>
> >Do you think there should be a UNIVERSAL::isa() function
> >so that $obj->isa("thngiehtingie") would quickly and efficiently
> >report whether $obj was derived from class "thingie"?
>
> I've always resisted marches through @ISA, hoping we'd come up with
> something faster or that if would never have to be done at all, but I guess
> that fell apart when I said that "an object is an object is an object" is
> sometimes insufficient in Perl.
>
> I think we'd have to start at the beginning and fix sv_isa(). Then make
> sv_isa() available as UNIVERSAL::isa(). I guess it's a march through
> @ISA...ug.
>

Why not cache the results on a magic for the package stash?

Ilya
Re: isa (Re: "Line Noise" considered offensive) [ In reply to ]
On Thu, 19 Oct 1995, Dean Roehrich wrote:

> >From: Tom Christiansen <tchrist@alumni.cs.colorado.edu>
>
> >Do you think there should be a UNIVERSAL::isa() function
> >so that $obj->isa("thngiehtingie") would quickly and efficiently
> >report whether $obj was derived from class "thingie"?
>
> I've always resisted marches through @ISA, hoping we'd come up with
> something faster or that if would never have to be done at all, but I guess
> that fell apart when I said that "an object is an object is an object" is
> sometimes insufficient in Perl.
>
> I think we'd have to start at the beginning and fix sv_isa(). Then make
> sv_isa() available as UNIVERSAL::isa(). I guess it's a march through
> @ISA...ug.
>
> I cringe when I think of all the calls to isa() that people will put in
> their code. They'll probably even use it on $self, of all things. Oh yes,
> load those modules up with isa() calls, unnecessary in most situations, then
> wonder why the app is so slow. It is times like these when I wish Perl
> supported pre/post -conditions with a compile-time switch to control them.
>
> But, grinch that I am, I recognize that there are times when you do need to
> know the implementation and ancestry of the object.

My thought is to make it work like an operator:

if( $fh isa "FileHandle" ) {
};

$s = {};
if( $s isa "HASH" ) {
};

In other words, there is no mechanism to trace the ancestory, just report
whether it's a derivative or not, and roll in the common usage of ref().

> Dean

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)