http://www.perlmonks.org?node_id=15186

rvbijl has asked for the wisdom of the Perl Monks concerning the following question:

Is this call frowned upon? &method($objectref, $more_params)?

Originally posted as a Categorized Question.

  • Comment on Is this call frowned upon? &method($objectref, $more_params)?

Replies are listed 'Best First'.
Re: Is this call frowned upon? &method($objectref, $more_params)?
by merlyn (Sage) on May 28, 2000 at 21:34 UTC
    Why not just
    $objectref->method(@more_params)
    ? What are you gaining by your "method" (heh) except the chance to miss out on inheritance?
      The reason being is that I have a of languageX => \&init_languageX, and I want to just get the method funciton from the hash instead of doing a lot of ifs. But, i couldn't get the call to work without doing it my way. Why would it lose out on inherritance, if $self we got it like this:
      sub set_lang { my $self = shift; my $lang = shift; ... &{$lang_to_func{$lang}}(...); }
      --
      Ryan -- http://www.calvin.edu/~rvbijl39
Re: Is this call frowned upon? &method($objectref, $more_params)?
by Anonymous Monk on May 28, 2000 at 22:16 UTC
    Ummm, doing it this way, your method has to be imported into the current name space.
Re: Is this call frowned upon? &method($objectref, $more_params)?
by alyons (Initiate) on May 30, 2000 at 22:29 UTC
    it is not the object oriented way. I am not a OO person. I prefer the way you have done it, especially if $objectref is a typeglob reference and $more_params is a list.