in reply to Syntax question: Method call, where method name is calculated from an expression

Sorry, this design looks strange, IMHO it breaks OOP paradigms.

Is there a reason why you don't add the dispatcher as an extra method to the class MyObj?

$obj->dispatcher(@arguments)

And even if you need this flexibility and don't care about encapsulation and DRY, you can still define a method call():

$obj->call(dispatcher(), @arguments)

giving you more and deeper possibilities to catch possible errors.

Cheers Rolf

Replies are listed 'Best First'.
Re^2: Syntax question: Method call, where method name is calculated from an expression
by rovf (Priest) on Jan 21, 2010 at 14:12 UTC
    (Sorry for the late response. I had an accident and was "away from Perl" for nearly 7 weeks)
    Sorry, this design looks strange, IMHO it breaks OOP paradigms.

    It does so on purpose. The code in question has to do with introspection, i.e. method name and arguments come from the outside. See it as kind of a debugging aid.

    Aside from this, I found the question by itself interesting too ;-)
    -- 
    Ronald Fischer <ynnor@mm.st>