* Shevek ([EMAIL PROTECTED]) [030706 17:28]:
> On Sun, 6 Jul 2003, Jonathan Peterson wrote:
> Perhaps this will illustrate.
> 
> sub new {
>       my $class = shift;
>       my $type = shift;
>       $class .= "::$type";
>       return $class->new(@_);
> }

An then in Acme::$type you read

  sub new()
  {   my $class = shift;
      $class->SUPER::new(...);
  }

Well.... no... probably you want something like this (in which case
the init() method does the real job):

 package Acme::Base;
 sub new
 {   my $class = shift;
     (bless {}, $class)->init( { @_ } );
 }
 sub init($) {shift}


 package Acme;
 use base 'Acme::Base';

 sub new
 {   my $class = shift;
     my $type  = shift;
     "$class::$type"->SUPER::new(@_);
 }

 sub init($)
 {   my ($self, $args) = @_;
     $self->SUPER::init($args);
     $self->{A_value} = $args{value} || 10;
     $self;
 }


 package Acme::Scalar;
 use base 'Acme';

 sub init($)
 {  my ($self, $args) = @_;
    $self->SUPER::init($args);
    $self->{AS_type} = 'Scalar';
    $self;
 }

And then, you hopre that Acme::new is smart enough to autodetect 'type'.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [EMAIL PROTECTED]                          [EMAIL PROTECTED]
http://Mark.Overmeer.net                   http://solutions.overmeer.net

Reply via email to