On Thu, Aug 03, 2017 at 08:44:45PM +0200, hw wrote:
> 
> Hi,
> 
> suppose I have a class FOO and a class BAR.  The parent of BAR is FOO.
> 
> I would like FOO to /use/ BAR because BAR has some methods needed by FOO.
> BAR is /decended/ from FOO because FOO has many methods needed by BAR.
> 
> Is this possible, or does it lead to some endless recursion when compiling?

You may well find that using roles would provide a better solution than
using inheritance.  The methods would wish to call from both classes
could be defined in one or more roles.  Roles are more usually called
traits in other languages.  You can use roles within Moose or Moo, or by
using other CPAN modules.  You can read more about roles/traits at

  https://en.wikipedia.org/wiki/Trait_(computer_programming)

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to