Slash Boxes
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

use Perl Log In

Log In

[ Create a new account ]

Thursday July 14, 2005
08:48 PM

Template::Extract is a lit bit cooler

[ #25714 ]

I wanted to use Template::Extract today, but found it couldn't handle my template. It turned out that by changing the options to the Template::Parser object that Template::Extract::Compile uses I could get the behaviour I needed. I modified the module so I could pass in my own Template::Parser object.

Thank god it was that simple, because I didn't want to mess with those regexen.

So, now Template::Extract has a patch waiting in RT.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Calling UNIVERSAL::isa() [] is almost always wrong.

    • It's done elsewhere in the module, so if Autrijus decides he doesn't want to do it like that, he can change it.
      • When I wrote UNIVERSAL::isa autrijus was right next to me helping me pitch ideas...

        I said that it stupid people do UNIVERSAL::isa, and after a while I said it again, and on the third time or so he implied that he doesn't like being called stupid... ;-)

        Either way, he said he'll use the isa function exported from UNIVERSAL::isa directly so that he doesn't need to call Scalar::Util::blessed.

        Since I exposed this deep dark secret, now you both have to do it, or else.
        • Besides Test::MockObject breaking, why else do you hate UNIVERSAL?

          I don't really like using subsets of Perl only because somebody's black magic mojo can't deal with it (and even more so when I don't want to use that mojo anyway ;)
          • Well, for me Test::MockObject is reason enough... Either way, since ->isa is OOP, and oop is about encapsulation, it should be encapsulated, IMHO.

            Polymorphism is all about an object adhering to some interface. If it can do that, it's consumers should be happy.

            If an object claims it is of some class, then it's impolite (and black magic mojoish, in a way) to interfere with that.
            • Perl is not a object language, and there are a lot of things you can't call methods on. Since any of those things might show up at any time, you can't simply use a method call to check to see if it is the right sort of object if you don't have an object. You can't impose object rules on everything in Perl.

              The function form of isa() exists to handle things that aren't objects. No matter what we think the world should be like, we know that users do all sorts of wacky things.

              I'm not going code a certain way s
              • I'm not arguing that perl is an object language, I'm arguing that in the OOP subset of perl you want objects to play nice, and this includes not calling


                instead of


                because $object might be a subclass..

                UNIVERSAL::isa is a method that knows to double as a function, but it's still a method..

                UNIVERSAL::isa (the module) replaces UNIVERSAL::isa (the subroutine), so no, Test::MockObject can't do the magic on it's own.
                • Params::Validate solves the problem that UNIVERSAL::isa() already does? No thanks. Note that perlobj and UNIVERSAL specifically mention the use of isa() the function for testing inheritance. It's why isa() exists. Indeed, the can( OBJECT, METHOD ) syntax makes no sense if this wasn't the intent.

                  We'll just have to disagree on this one, and you'll just have to include me with the other stupid module authors. If I have to use Test::MockObject for something, I'll just make the fix to it myself.
        • I choose "or else". Look, my UNIVERSAL::isa call in Template::Extract is testing whether it's a scalar reference:
          $var = $$var if UNIVERSAL::isa($var, 'SCALAR');
          I think this use is legit, especially as I suspect people who actually overload ${} do not usually bother redefining their isa method to include SCALAR.
  • I end up choosing another API. Easy things should be easy -- i.e. directly passing parser options into Template::Extract->new() -- and hard things should be possible -- namely subclassing T::E to use another parser subclass instead of relying on "isa" relationship. Thanks for the suggestion!