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.
Re:Contracts
statico on 2005-02-01T06:27:06
n1vux++
Wow, I suck. See the "UPDATE" above.Re:Contracts
n1vux on 2005-02-03T20:28:55
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 use.perl.org
;-)