in reply to Re: Feedback: Strongly-typed "Pascal records" module
in thread Feedback: Strongly-typed "Pascal records" module

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.

  • Comment on Re: Re: Feedback: Strongly-typed "Pascal records" module