in reply to
Re: Re: •Re: It's a dog, but what kind? (polymorphism , in Perl OO)
in thread It's a dog, but what kind? (polymorphism , in Perl OO)
As you say, it's also possible to load all the subclasses before anything is called, but that could get very inefficient fast.
Understood. It could be a killer. As a non-perl example, Sun did something like this with java import in 1.4.x, and we saw numerous performance issues -- and we ended up reimplementing lazy loading of some plugins with reflection (i.e. equivalent of symbol tables) -- ugly!
My favored solution would be to map a breed via a hash:
Great idea, chief! I'd probably use both the hash and require for purity's sake -- and call the import explicitly. You might (I'm theorizing) save a little performance from not using eval at all in that case. But yeah, then you would lose the exception catching (eval block)???