I have the following situation:
So far, so good, right? The problem is in the <readmore>
HTML::Template uses ref all over the place. One thing is does is check to see if the value of a parameter is an arrayref. If it is, then it assumes that you're using it for a <TMPL_LOOP> and complains if it's being used for a <TMPL_VAR>. My self-formatting nubmers are meant for <TMPL_VAR> usage. So, we have a case of where I have to do this in my self-formatting number class. (I should move it to the base class, frankly.)
{ my %is_internal_type = map { $_ => 1 } qw( ARRAY HASH SCALAR GLOB CODE ); sub isa { my $self = shift; my ($type) = @_; return if $is_internal_type{$type}; return $self->SUPER::isa($type); } }
All because HTML::Template uses ref. And, it's not just HTML::Template. Most modules that have much dwimmery suffer from the same ... lack of discernment.
Figure out another way. Use class names and provide a factory, use different function name to provide different signatures, anything! Just don't use ref!
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In reply to Why ref() is bad.
by dragonchild
in thread Is "ref $date eq 'ARRAY'" wrong?
by bronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |