1. You asked me why it was bad in *this* case. My answer is simple, it is
not just bad in this case, it is bad in all cases, including this one. This is
something about principle.
This is similar to a parent saying "Cause I'm the adult" when explaining the
reason for a rule to a child. It doesn't *explain* anything, and seems to
me to be a cop-out. I don't believe that there is anything principle about
this argument. It has evolved over time to the point where people are so used
to hearing "It's bad" that they just believe it.
It is just like you ask me why "goto" is bad in
*this* case, I will say, no, it is bad in every case, you should never ever use
it.
Unless you need to trick caller() from inside AUTOLOAD? Or even then, would you
forsake its goodness for a more convoluted solution because you know "It's
bad"?
Whatever you archieved here, can be easily archieved by using a hash
containing all coderef's (hard ones).
With the added maintainance and wasted space of a dispatch table stored in
a hash, yes.
What is the point to violate principles,
when you can complete the same task by following the principles, and gain more
maintainablility and flexibilty?
I don't adhere to "principles" that make things less maintainable and less
flexible, and disagree with the statement that the hash based dispatch table
improves those things.
2. Modern programming no longer appreciates smart tricks that much, on thecontrary, we strongly stress the importance of maintainability more than
ever.
That's a pretty nebulous statement. But I do agree that maintainability is
important. I am arguing that adding a hash as a dispatch table decreaces
maintainability in this case.
To make your piece of code work, it requires to turn off "use strict".
You may argure that we can just turn off use strict refs for that particular
lexical scope to reduce the danger, but still someone maintain your code may
add some bad code into that lexical scope, and miss the chance of correcting it
in the first place, all because "use strict" is turned off.
"use strict" is not turned off. "strict refs" is turned off explicitly, which
explicitly allows use of symbolic references. As an aside, I think it is
pretty funny that in order to leave "strict refs" turned on and use the
dispatch method I did, I have to use the one exception to the no-symbolic-refs
rule that "strict refs" enforces. It exists so people people can use goto and
a symbolic reference to a subroutine under stricture.
To be frank, after couple of months, even you may forget that that piece
of code is a mine field. Does this not happen all the time to us?
I may be wrong, but I don't think it is mine field. Nothing you have said has
convinced me of that, to be sure.
A really dangerous thinking in programming is to assume everything will go well by its own. That is never true.
I don't know that means.
Thanks very much for the response,
pg.
-- dug