Re: What is the best way to set options in a constructor

2003-10-24 Thread R. Joseph Newton
Sorry, this was clumsy and graceless: "R. Joseph Newton" wrote: > sub new { > ... > }else { > $self->initialize(@_); >} >return $self; > } > It works much better without the else here. Inializing with the remainder of the parameter list allows ad-hoc expansion of the object at

Re: What is the best way to set options in a constructor

2003-10-24 Thread R. Joseph Newton
Wiggins d Anconia wrote: > > my $new_obj = ref($obj)->new; Ouch! Unfortunately, I can well imagine someone trying to use that, too. > I do have to differ with the opinion about new, if you really are just > constructing an object then to me it still makes sense as a name, but in > the case of D

Re: What is the best way to set options in a constructor

2003-10-24 Thread R. Joseph Newton
Steve Grazzini wrote: > On Thu, Oct 23, 2003 at 06:48:29AM -0700, R. Joseph Newton wrote: > > "Randal L. Schwartz" wrote: > > > > "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes: > > > > > > Dan> my $class = ref($proto) || $proto; > > > > > > Don't do this! > > > > I'm still a little mystif

Re: What is the best way to set options in a constructor

2003-10-23 Thread R. Joseph Newton
"Randal L. Schwartz" wrote: > > "R" == R Joseph Newton <[EMAIL PROTECTED]> writes: > > R> "Randal L. Schwartz" wrote: > >> > "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes: > >> > Dan> my $class = ref($proto) || $proto; > >> > >> Don't do this! > >> > >>

Re: What is the best way to set options in a constructor

2003-10-23 Thread Wiggins d Anconia
> > "Steve" == Steve Grazzini <[EMAIL PROTECTED]> writes: > > Steve> Now, I don't particularly like "$obj->new", but it's not really "wrong" > Steve> either. If you want to let people call your constructor that way, then > Steve> go ahead and use "ref($proto) || $proto". And conversely, if

Re: What is the best way to set options in a constructor

2003-10-23 Thread Randal L. Schwartz
> "Steve" == Steve Grazzini <[EMAIL PROTECTED]> writes: Steve> Now, I don't particularly like "$obj->new", but it's not really "wrong" Steve> either. If you want to let people call your constructor that way, then Steve> go ahead and use "ref($proto) || $proto". And conversely, if you think S

Re: What is the best way to set options in a constructor

2003-10-23 Thread Steve Grazzini
On Thu, Oct 23, 2003 at 06:48:29AM -0700, R. Joseph Newton wrote: > "Randal L. Schwartz" wrote: > > > "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes: > > > > Dan> my $class = ref($proto) || $proto; > > > > Don't do this! > > I'm still a little mystified as to what you find offensive there.

Re: What is the best way to set options in a constructor

2003-10-23 Thread Randal L. Schwartz
> "R" == R Joseph Newton <[EMAIL PROTECTED]> writes: R> "Randal L. Schwartz" wrote: >> > "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes: >> Dan> my $class = ref($proto) || $proto; >> >> Don't do this! >> >> . R> Hi Randal, R> Read the

Re: What is the best way to set options in a constructor

2003-10-23 Thread R. Joseph Newton
"Randal L. Schwartz" wrote: > > "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes: > > Dan> my $class = ref($proto) || $proto; > > Don't do this! > > . Hi Randal, Read the article, and it percursor thread. I'm still a little mystified as to

Re: What is the best way to set options in a constructor

2003-10-23 Thread R. Joseph Newton
James Edward Gray II wrote: > > my $self; > > $self isn't a reference to a hash, even though you're about to start > using it like one. > > my $self = { }; > > > $self->{BOOL_1} = 0; > > $self->{BOOL_2} = 0; Actuaqlly, it will work the way he has it. The anonymous hash is auto-vivified on

Re: What is the best way to set options in a constructor

2003-10-18 Thread Randal L. Schwartz
> "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes: Dan> my $class = ref($proto) || $proto; Don't do this! . -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> http://www.stonehenge.com/merly

Re: What is the best way to set options in a constructor

2003-10-17 Thread Rob Dixon
Wiggins D'Anconia wrote: > Dan Anderson wrote: > > > I have a package which I wanted to make an object, so I had something > > like the following: > > > > sub new { > > my $proto = shift; > > my $class = ref($proto) || $proto; > > my $self; > > $self->{BOOL_1} = 0; > > $self->{BOOL_2} =

Re: What is the best way to set options in a constructor

2003-10-16 Thread James Edward Gray II
On Thursday, October 16, 2003, at 02:35 PM, Dan Anderson wrote: I have a package which I wanted to make an object, so I had something like the following: sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self; $self isn't a reference to a hash, even though you're about to

RE: What is the best way to set options in a constructor

2003-10-16 Thread Wiggins d'Anconia
On Thu, 16 Oct 2003 15:35:22 -0400, Dan Anderson <[EMAIL PROTECTED]> wrote: > I have a package which I wanted to make an object, so I had something > like the following: > > sub new { > my $proto = shift; > my $class = ref($proto) || $proto; >

What is the best way to set options in a constructor

2003-10-16 Thread Dan Anderson
I have a package which I wanted to make an object, so I had something like the following: sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self; $self->{BOOL_1} = 0; $self->{BOOL_2} = 0; # etc... while (shift) { $self->{$_} = 1; } bless $self, $class