Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • The "blessed( $arg ) && $arg->isa('Some::Class')" idiom is not necessary. You can do

    #!perl -l
    $x = {};
    print UNIVERSAL::isa($x,"Foo::Bar") ? 1 : 0;
    print UNIVERSAL::isa($x,"HASH") ? 1 : 0;
    __END__
    0
    1

    (as documented in the UNIVERSAL manpage)
    • Re:UNIVERSAL::isa (Score:2, Interesting)

      by james (1129) on 2003.06.10 6:36 (#20959) Homepage Journal
      I know, I was using it as a small, trite example. The actual problem is that its easier to refactor away conditions if everything is an object - which is my real dislike. I felt going into why I like to refactor away conditions was probably beyond the scope of the journal entry, which was more about having HASH/ARRAY/SCALAR/... objects, and the nice things that you can do once you have them.
      • And by the way are you going to upload magicrefs to some comprehensive perl archive network ?
        • It's essentially a patch against pp.c in the perl source. I could put it on CPAN, but it seems like a strange place to put a patch. I think it might be possible to do something similar with optimizer.pm, but I need to talk to sky a little about that.
          • Ah. You're evil, then ;-) If this is a core patch, then I don't understand what's in magicrefs.pm -- is it a lexical pragma ? What core function(s) are you patching, and to do what ?
            • magicrefs.pm is a pragma similar to sort, ie, not lexical.

              Essentially it alters S_refto in pp.c. magicrefs.pm sets a hint that is examined in S_refto to determine whether or not we should bless all references that are created (with the exception of those that are SvREADONLY). magicrefs also use's the various reftype modules.