develooper Front page | perl.perl6.language | Postings from June 2005

Re: construction clarification

Thread Previous | Thread Next
Carl Franks
June 1, 2005 01:35
Re: construction clarification
Message ID:
> It's *a* correct way. But redundant in this particular case.
> The universal new() would handle the one-argument call exactly the same
> as your overloaded new() does. Presumably, however, the one-argument variant
> would do something else as well.

Some people will need to call the constructor with a whole host of options:

my $foo =
  date => '2005-06-01',
  other => 1,
  params => 1);

For the typical case though, rather than forcing people to have to write
my $foo =
  date => '2005-06-01);

they should be able to write
my $foo ='2005-06-01');

However, if I allowed the default 'new' to handle that case, then the
BUILD submethod has to be aware of that.
I thought it would be cleaner to 'document' the special case with a
seperate constructor, and also not require any special-case logic in the
BUILD submethod.

Is that really off the wall?


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About