Re: OOP: a class using a class that is descended from it?

2017-08-05 Thread Paul Johnson
On Fri, Aug 04, 2017 at 05:45:08PM +0200, hw wrote: > Paul Johnson wrote: > > 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

RE: OOP: a class using a class that is descended from it?

2017-08-04 Thread Duncan Ferguson
You may also find the following docs useful http://modernperlbooks.com/books/modern_perl_2016/03-perl-language.html#UGFja2FnZXM http://modernperlbooks.com/books/modern_perl_2016/07-object-oriented-perl.html#T2JqZWN0cw (see Moose and Blessed References) The index of the book is at

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Shawn H Corey
On Fri, 4 Aug 2017 17:51:01 +0200 hw wrote: > Huh? How many package statements is a module supposed to contain? > And doesn´t a package statement turn a module into a package? Convention is: * One package per module. * One module per package. But if come across bad code, you

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Chas. Owens
> > What happens when you bless something in a module? > In Perl 5 an object is a reference that has been blessed (with a package name). The namespace of that package is used to find the methods associated with the object. If no methods can be found, then the @ISA package variable is checked to

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Chas. Owens
On Fri, Aug 4, 2017 at 11:52 AM hw wrote: > > Often you will see a module that contains one package statement which > leads to the confusion. > > Huh? How many package statements is a module supposed to contain? > And doesn´t a package statement turn a module into a package? >

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread hw
Shawn H Corey wrote: On Fri, 4 Aug 2017 15:23:21 +0200 hw wrote: Now I´m confused as to what is a module and a package. Both are files. > [...] This is very confusing so the convention is that one module has one package. I'm telling you this because the terms module and

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Uri Guttman
On 08/04/2017 11:51 AM, hw wrote: Huh? How many package statements is a module supposed to contain? And doesn´t a package statement turn a module into a package? package statements and files are independent! a package statement only sets the default namespace for code that follows it until

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread hw
Chas. Owens wrote: On Fri, Aug 4, 2017 at 9:25 AM hw > wrote: snip Now I´m confused as to what is a module and a package. Both are files. No, packages are not files. A package is created by a package statement: package Foo; This I put into a

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread hw
Paul Johnson wrote: 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.

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Shawn H Corey
On Fri, 4 Aug 2017 15:23:21 +0200 hw wrote: > Now I´m confused as to what is a module and a package. Both are > files. > > In any case, it is my intention to keep everything that one class > requires within one file which starts with 'package FOO'. Due to > increasing

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread hw
Илья Рассадин wrote: Hi! It's strange design decision. If FOOR is ancestor for BAR, why can't you just place methods into FOO? It´s because not both of FOO and BAR can have all the same methods. Yet there is functionality programs using FOO and/or BAR require from both of them from

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Chas. Owens
On Fri, Aug 4, 2017 at 9:25 AM hw wrote: snip > Now I´m confused as to what is a module and a package. Both are files. > No, packages are not files. A package is created by a package statement: package Foo; If you do not explicitly create a package with a package statement,

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread hw
Andrew Solomon wrote: On Thu, Aug 3, 2017 at 8:48 PM, hw > wrote: Andrew Solomon wrote: My instinct before trying this would be to move the methods which FOO needs back into FOO (removing them from BAR). Is there a reason this won't

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread hw
Shawn H Corey wrote: On Thu, 3 Aug 2017 20:44:45 +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

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Paul Johnson
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

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Илья Рассадин
Hi! It's strange design decision. If FOOR is ancestor for BAR, why can't you just place methods into FOO? 03.08.17 21:44, hw пишет: 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

Re: OOP: a class using a class that is descended from it?

2017-08-03 Thread Shawn H Corey
On Thu, 3 Aug 2017 20:44:45 +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

Re: OOP: a class using a class that is descended from it?

2017-08-03 Thread Andrew Solomon
On Thu, Aug 3, 2017 at 8:48 PM, hw wrote: > Andrew Solomon wrote: > >> My instinct before trying this would be to move the methods which FOO >> needs back into FOO (removing them from BAR). >> >> Is there a reason this won't work for you? >> > > Hmm. I haven´t thought of that

Re: OOP: a class using a class that is descended from it?

2017-08-03 Thread hw
Andrew Solomon wrote: My instinct before trying this would be to move the methods which FOO needs back into FOO (removing them from BAR). Is there a reason this won't work for you? Hmm. I haven´t thought of that because they don´t belong into FOO. They also won´t work in FOO because both

Re: OOP: a class using a class that is descended from it?

2017-08-03 Thread Andrew Solomon
My instinct before trying this would be to move the methods which FOO needs back into FOO (removing them from BAR). Is there a reason this won't work for you? On Thu, Aug 3, 2017 at 7:44 PM, hw wrote: > > Hi, > > suppose I have a class FOO and a class BAR. The parent of BAR is