Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Re: Feedback: Strongly-typed "Pascal records" moduleby aspen (Sexton) |
on Jan 01, 2003 at 21:37 UTC ( [id://223627]=note: print w/replies, xml ) | Need Help?? |
Replying to both John M. Dlugosz and pg, you are right about the variety of related hash-checking and field-checking pragmas and modules that exist. The particular goal here was about type checking during the assignment of a value to one of an object's instance variables. The "type" of the assigned value must match the "type" expected for that key. When following general OO rules this means checking the module author's action, since non-authors are generally supposed to use module-author accessor methods to modify instance data. (Though Tie::Record will check extra-package assignments as well.)
It wasn't my particular goal to validate/examine whether a derived module was validly implementing it's parent's (or parents') interface. Rather, enable Perl to say to me "Yo, coder, I don't think you did what you meant to do. Isn't this particular object's xxxx instance variable supposed to hold Foo::Bar objects and not Bar::Foo objects!?" It ensures my mis-assignment to an instance variable gets noticed at its source instead of (much) later when its effect finally shows up.
In Section
Meditations
|
|