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 meth

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

2017-08-04 Thread Duncan Ferguson
://modernperlbooks.com/books/modern_perl_2016/index.html if you want more details of other parts of Perl Duncs -Original Message- From: hw [mailto:h...@gc-24.de] Sent: 04 August 2017 17:31 To: beginners@perl.org Subject: Re: OOP: a class using a class that is descended from it? Shawn H Corey

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 may see more than

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? > No, package statem

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 package are not in

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 mailto:h...@gc-24.de>> 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 file. If you do no

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 complexity, I´m using POD

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 different

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, then you are in t

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 mailto:h...@gc-24.de>> 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?

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 needed by BAR. Is th

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 th

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 BAR. > > Is this p

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 because they don´t

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 FO

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 FOO. > > I would

Re: oop array question

2011-09-03 Thread Rob Dixon
On 03/09/2011 12:22, Ron Weidner wrote: I'm trying to add a object to an array of objects. The code below is wrong. sub add_widget { my $self = shift; my $new_widget = shift; push ( @($self->{WIDGETS}), $new_widget ); } Hi Ron You probably want push @{$self->{WIDGETS}}, $n

Re: OOP in Perl

2008-02-16 Thread Randal L. Schwartz
> ""Jeff" == "Jeff Pang" <[EMAIL PROTECTED]> writes: "Jeff> but the second one is recommended, it looks more like the OO way. It's more than just recommended. The indirect object form is actively discouraged, because we've been finding more and more examples where the inherent imbiguity in i

Re: OOP in Perl

2008-02-16 Thread Jeff Pang
On Feb 15, 2008 11:56 PM, howa <[EMAIL PROTECTED]> wrote: > Hi, > > Currently I have seen two way to create objects in Perl: > > 1. my $a = new Apple... > 2. my $a = Apple->new(); > > What are the differences, and which one is recommended? > Both are fine: $ perl -le 'package A;sub new{print shif

Re: OOP inheritance question (simple)

2005-12-07 Thread John Doe
Ken Farmer am Donnerstag, 8. Dezember 2005 02.28: [...] > I agree that I need a perl object book. Not necessarily - it could even be better to buy a book that contains the OO paradigmas independent from any programming language. The details of the language (or the focus on implementation) cou

Re: OOP inheritance question (simple)

2005-12-07 Thread Wiggins d'Anconia
Ken Farmer wrote: > > Wiggins d'Anconia <[EMAIL PROTECTED]> wrote: > > See the other posters responses as well, but I think it might help if > you read through some docs on OOP programming, check out: > > perldoc perlboot > perldoc perltoot > perldoc perltooc > > And issuing, > > perldoc perl

Re: OOP inheritance question (simple)

2005-12-07 Thread Ken Farmer
Wiggins d'Anconia <[EMAIL PROTECTED]> wrote: See the other posters responses as well, but I think it might help if you read through some docs on OOP programming, check out: perldoc perlboot perldoc perltoot perldoc perltooc And issuing, perldoc perl Thanks for the response, and the other res

Re: OOP inheritance question (simple)

2005-12-07 Thread Wiggins d'Anconia
Ken Farmer wrote: > I have tried this question in a couple of other places but the answers are > far above my current level of understanding of oop - which is the level of > very interested newbie - real newbie. So here goes again. > > I make an empty (of data) perl object1 with an included m

Re: OOP inheritance question (simple)

2005-12-07 Thread Randal L. Schwartz
> "Xavier" == Xavier Noria <[EMAIL PROTECTED]> writes: Xavier> package class2; Xavier> use base 'class1'; Except of course, lowercase package names are reserved for pragmata. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/

Re: OOP inheritance question (simple)

2005-12-06 Thread Xavier Noria
On Dec 7, 2005, at 4:36, Ken Farmer wrote: I have tried this question in a couple of other places but the answers are far above my current level of understanding of oop - which is the level of very interested newbie - real newbie. So here goes again. I make an empty (of data) perl objec

RE: OOP

2002-11-27 Thread NYIMI Jose (BMB)
For such simple class (no inheritance ...), you can just use the standard module Class::Struct, it will built constructor and accessors for you. Then like Paul said : "Just write a method (called 'init' in the example below) which accepts the string,splits on the semi-colon, and assigns the result

Re: OOP

2002-11-26 Thread Ramprasad A Padmanabhan
Well I use the AUTOLOAD when Such a thing is required write a single function sub AUTOLOAD { my $self = shift; my ($parameter)=shift; my ($value)=shift; $self->{$parameter} = $value if($value); return $self->{$parameter}; } Now U can use $obj->CNAME("ABC"); But we warned

Re: OOP

2002-11-26 Thread Ovid
--- Nicole Seitz <[EMAIL PROTECTED]> wrote: > Hi there! > > I've just started to learn OOP with Perl.With the help of perltoot I wrote a > class Person and some methods(see below). 'perltoot' is great, but there are a few things that can be done differently. Admittedly, it's aimed at beginners

Re: OOP

2002-11-26 Thread Paul Johnson
On Wed, Nov 27, 2002 at 12:12:46AM +, Nicole Seitz wrote: > Hi there! > > I've just started to learn OOP with Perl.With the help of perltoot I wrote a > class Person and some methods(see below). > > package Person; [ snip implementation ] > To store some data in my object I did the follwi

Re: OOP Mailing lists

2002-10-22 Thread Peter Scott
There is an on-line forum for people who have read Damian Conway's book, at http://www.manning.com/getpage.html?project=conway&filename=forum.html And anyone who is serious about OO Perl will read that book. -- Peter Scott http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: OOP Mailing lists

2002-10-21 Thread Wiggins d'Anconia
LRMK wrote: Can any body tell me a address of a OOP mailing list for perl Surprisingly I didn't see one specifically for that topic. Although most questions on this topic could certainly be posed to the beginners list as it is pretty general. There is a nice list of lists at: http://lists.

Re: OOP & Perl. References to methods

2001-08-22 Thread Mark Maunder
Lakka, Why are you passing the scalar object reference by reference to your function? Just pass it as per normal and it will save you dereferencing it with $$. Also, why do you have a '\' char before $_[0]? You're creating another reference there. And are you actually blessing $dxfInstance into a

RE: OOP & Perl. References to methods

2001-08-22 Thread Bob Showalter
> -Original Message- > From: Lakka Sami [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 22, 2001 8:51 AM > To: [EMAIL PROTECTED] > Subject: OOP & Perl. References to methods > > > Hi, > > I'm having problems with OOP and Perl. I have an class > named DXFobject and an other class th