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.
  • by Alias (5735) on 2007.12.08 17:58 (#59349) Homepage Journal
    You surely mean of course (defined $it and blessed $it and $it->isa('Foo'))...
    • That's a lot longer to type and while it's theoretically clearer, I don't think it wins over an eval. Did I miss something obvious?

      • In general, using eval willy nilly is not good because you might swallow an exception that should have bubbled up. But a properly working isa is not expected to throw exceptions (or so I hope), so this idiom seems just fine.

        • You're absolutely right. An overridden isa() that throws an would violate the Liskov substitution principle, so it would not in fact work properly.

    • No, I think you meant

      defined( blessed $it ) and $it->isa( '...' )
      . blessed() is not a sufficient boolean on its own. There are two false classes in perl.