in reply to Re: Object passing within a package
in thread Object passing within a package

This situation looks a bit odd. Why are you creating another object inside a method call and using that as an argument to another method?

First, why must barsub() be a method? Why isn't it a function?

I can think of at least two reasons to do this:

  1. barsub() is a utility function defined to do something useful. barsub() may actually be _barsub().
  2. barsub() is a utility function that comes from some other library of functions.

As for why foosub() instantiates the Some::Module object then passes it to barsub(), you could have foosub2() that instantiates an object from Other::Module and passes it to barsub().

You just never know.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^3: Object passing within a package
by brian_d_foy (Abbot) on Jan 17, 2005 at 17:04 UTC

    In the example, it looks like barsub() in that same package as foosub(), which is a method. If barsub() has nothing to do with that same package or object, it's in the wrong place. If the situation is different, then the example code has way too much detail, and we don't need to know anything about anything else than barsub().

    I don't know what the original poster is doing, but it looks like an odd design. That's why I asked. I'm not trying to guess what the he is actually doing. I'm just asking why he's doing it that way, and I'll wait to see what he says, and then I'll know (which is sooner than never ;).

    --
    brian d foy <bdfoy@cpan.org>