Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Objects are not different than primitive Perl datastructures. I guess I was a little loose with my usage of the word "object" in that quote, but I simply meant "a thing" and not specifically a blessed reference. HTML::Template currently will take any hashref, blessed or unblessed. But the point is that H::T doesn't hinge on any internal hash magic -- all it needs from the "things" you pass is the interface of a hashref. A blessed arrayref can have this interface, but the way HTML::Template checks its input makes it very hard to successfully get this to work.
The documentation for HTML::Template says to pass it in hashrefs, etc -- "plain old reference" datastructures. But blessed objects can be used seamlessly as "plain old reference" datastructures, either by being the correct type of blessed reference, or by overloading the appropriate dereferencing operators. I'm just suggesting a more complete way of checking for the type of a datastructure that includes these possibilities. It's like writing a sub that requires a scalar, so you have some code to verify the input is a scalar. But the verification code fails for a tied scalar. That would be ridiculous. We have tied objects so we can use the "plain old variable" interface seamlessly. We also have the ability to overload dereferencing operators -- for what other reason than to use the "plain old reference" interface? blokhead In reply to Re: Re: "Is it a hashref" vs "Can I use it like a hashref?"
by blokhead
|
|