Re: construction clarification

2005-06-01 Thread Carl Franks
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

Re: construction clarification

2005-06-01 Thread Carl Franks
The universal new() would handle the one-argument call exactly the same as your overloaded new() does. Is that correct? S12 says... All classes inherit a default new constructor from Object. It expects all arguments to be named parameters initializing attributes of the same name. ...

Re: construction clarification

2005-06-01 Thread Damian Conway
Carl Franks wrote: The universal new() would handle the one-argument call exactly the same as your overloaded new() does. Is that correct? S12 says... All classes inherit a default new constructor from Object. It expects all arguments to be named parameters initializing attributes of

Re: construction clarification

2005-06-01 Thread Damian Conway
Carl Franks wrote: 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

Re: construction clarification

2005-05-31 Thread Damian Conway
Carl Franks wrote: I have a class that normally takes a list of named arguments. I also want to be able to handle a single argument. class Foo { multi method new (Class $class: Str $date) { return $class.bless(date = $date); } submethod BUILD ($.date, $.time, $.offset) { #

Re: construction clarification

2005-05-31 Thread Larry Wall
On Mon, May 30, 2005 at 05:00:26PM +0100, Carl Franks wrote: : I have a class that normally takes a list of named arguments. : I also want to be able to handle a single argument. : : class Foo { : multi method new (Class $class: Str $date) { : return $class.bless(date = $date); : } : :

construction clarification

2005-05-30 Thread Carl Franks
I have a class that normally takes a list of named arguments. I also want to be able to handle a single argument. class Foo { multi method new (Class $class: Str $date) { return $class.bless(date = $date); } submethod BUILD ($.date, $.time, $.offset) { # some error checking here