Re: Yet another OO question

2006-06-10 Thread JupiterHost.Net
Paul Johnson wrote: Astute readers may recognise the rules I am attempting to use. Damian Conway's Perl best Practices, *everyone* should own this book :) Mr. Johnson just got a few more points in my book ;p -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMA

Re: Yet another OO question

2006-06-10 Thread Paul Johnson
On Fri, Jun 09, 2006 at 09:18:22AM -0700, Lawrence Statton wrote: > Our local style guide bans the > use of for without an explicit index variable Every style guide should have a rule that says "break these rules if you consider it sensible to do so, but be

Re: Yet another OO question

2006-06-10 Thread Lawrence Statton
Shawn wrote: > > > > I would prefer it to return the old value: > > > > > > > > sub foo { > > > > my $self = shift; > > > > my $old_foo = $self->{'foo'}; > > > > $self->{'foo'} = shift if @_ > 0; > > > > return $old_foo; > > > > } > > > > > > > > Someone asked: (Sorry, I've lost the attr

Re: Yet another OO question

2006-06-08 Thread Anthony Ettinger
On 6/8/06, Lawrence Statton <[EMAIL PROTECTED]> wrote: > > I would prefer it to return the old value: > > > > sub foo { I see...I i've been more or less looking at the current state $curr = $foo->bar(); $old = $curr; $curr = $foo->bar('new value'); -- Anthony Ettinger Signature: http://cho

Re: Yet another OO question

2006-06-08 Thread Lawrence Statton
> > I would prefer it to return the old value: > > > > sub foo { > > my $self = shift; > > my $old_foo = $self->{'foo'}; > > $self->{'foo'} = shift if @_ > 0; > > return $old_foo; > > } > > > > > > If you set a new value, why would you want your client to still be > using the old value? B

Re: Yet another OO question

2006-06-08 Thread Anthony Ettinger
On 6/8/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: On Thu, 2006-08-06 at 10:56 -0700, Anthony Ettinger wrote: > i prefer the return once method: > > sub foo > { > my $self = shift; > if (@_ == 1) { $self->{'foo'} = shift; } > > return $self->{'foo'}; > } I would prefer it to re

Re: Yet another OO question

2006-06-08 Thread Mr. Shawn H. Corey
On Thu, 2006-08-06 at 10:56 -0700, Anthony Ettinger wrote: > i prefer the return once method: > > sub foo > { > my $self = shift; > if (@_ == 1) { $self->{'foo'} = shift; } > > return $self->{'foo'}; > } I would prefer it to return the old value: sub foo { my $self = shift; my $

Re: Yet another OO question

2006-06-08 Thread Anthony Ettinger
On 6/8/06, Ricardo SIGNES <[EMAIL PROTECTED]> wrote: * Graeme McLaren <[EMAIL PROTECTED]> [2006-06-08T05:44:05] > Hi all, I've just been reading a bit about accessor get/set methods. I > have a method: > > sub even{ >my $self = shift; >my $even = shift; > >$self->{_even} = $even if

Re: Yet another OO question

2006-06-08 Thread Ricardo SIGNES
* Graeme McLaren <[EMAIL PROTECTED]> [2006-06-08T05:44:05] > Hi all, I've just been reading a bit about accessor get/set methods. I > have a method: > > sub even{ >my $self = shift; >my $even = shift; > >$self->{_even} = $even if defined($even); >return $self->{_even}; > } >

Yet another OO question

2006-06-08 Thread Graeme McLaren
Hi all, I've just been reading a bit about accessor get/set methods. I have a method: sub even{ my $self = shift; my $even = shift; $self->{_even} = $even if defined($even); return $self->{_even}; } This basically does what a get and set method would do. So why would I need a