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 ]

statico (5018)

AOL IM: eisforian (Add Buddy, Send Message)


Co-author of Perl Testing: A Developer's Notebook []

Journal of statico (5018)

Sunday January 30, 2005
11:58 PM

making perl less like perl

[ #22949 ]

My friend and I, who are partners for a certain class we're taking this semester, had a good four-hour-long argument^Wdiscussion over how to make Perl more, well, formal. Specifically, we need contracts.

What this seems to boil down to is more anal methods. Instead of using something like Spiffy or Class::Accessor/Class::Constructor, which wouldn't [instantly] do any checking of arguments at all really, we want to make our methods and accessors perform more serious checking.

One solutions would be to use Class::Meta with Params::Validate, which would seem to make our code sit up more strait. However, Class::Meta provides no way of validating arguments to methods --- only accessors. This functionality may appear out of the scope of the module or require voodoo, but to us it simply feels incomplete.

Class::Construct seemed to rock our world until we realized it hadn't been touched since 2001 or 2002, and there are NO tests. Boooo!

UPDATE: I meant to say Class::Contract. Additionally, I was confused -- my partner and I were looking at the Class::Contract module that is in the Introspector-0.04 package, which is really old and not the newest. I take it back, since n1vux pointed out the real Class::Contract package!

Then we saw Sub::Assert, which provides the creation of pre- and post-conditions. Bingo! Thus, tonight's Ian award goes to Steffen Müller.

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.
  • Did you look at Damian's Class::Contract []?
    # I had a sig when sigs were cool
    use Sig;
    • n1vux++

      Wow, I suck. See the "UPDATE" above.
      qw(Ian Langworth)
      • Glad to be of service.

        Sub::Assert [] looks good for using pre/post conditions on subroutines instead of Class->methods, could be useful, thanks for pointing that out.

        I find that I need to use full pre/post-condition+Invariant proof-of-correctness about once a decade in normal programming. (Luckily, I was actually trained in it once, when we thought it might be relevant to computer security programming. I might be the only Ottawa Euclid [] programmer on ;-)

        # I had a sig when sigs were cool
        use Sig;