|
|
| Do you know where your variables are? | |
| PerlMonks |
Re: Class::Struct, Class::Contract and type Safetyby baku (Scribe) |
| on Feb 14, 2001 at 19:51 UTC ( #58362=note: print w/ replies, xml ) | Need Help?? |
|
Perhaps (probably) I don't rightly understand the question... but in my experience, the very fact that Perl is "weakly" typed has been a boon in large projects. For example, one current job I'm working on has over 500 separate small scripts (automated jobs working with various databases to perform specific functions) as well as several multi-thousand-line application "scripts," being maintained by as many as 50 people at any time. Since we don't have to worry about whether a subroutine expects a int or a long int, development has been remarkably easy. That said, every named subroutine we have does perform checking, not upon the "type" of the data, but upon its "domain." For example:
It looks like Class::Contract could be a useful tool to perform this sort of data validation, but relying upon "types" as a validity test (at least primitive types) is a very dangerous thing. OTOH, Perl does allow you to check object references, so if you accept data in the form of an object which contains already-validated data, you do have a "strong typing" system to work with: die "not Right::Class: $ref" unless ( ref $ref && $ref->isa("Right::Class") ); is one such example... Hope that is on task :-)
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||