in reply to Re: Whats wrong with symbol refs here?
in thread Whats wrong with symbol refs here?

Was using it at first. I thought it might be faster without the autoloader... if there are many child classes all the lookups would take more time than just creating real methods once at init. At least that seems to make sense.
  • Comment on Re: Re: Whats wrong with symbol refs here?

Replies are listed 'Best First'.
Re: Re: Re: Whats wrong with symbol refs here?
by runrig (Abbot) on Feb 05, 2002 at 10:54 UTC
    What do you mean 'just creating real methods once'?? AutoLoader can create the methods once (during the first call) then you can goto the method (this is considered a 'good' goto). I'm also not saying this is better than your way, the only advantage to this way is that the method never gets created if its never called.

      This is what I was referring to in my other writeup in this thread

      A real life example cut and paste from a production module :

      sub AUTOLOAD { my ( $self, $arg ) = @_; no strict 'refs'; (my $method = $AUTOLOAD ) =~ s/^.*:://; if ( exists $self->{_data}->{$method} ) { *{$AUTOLOAD} = sub { my ( $self, $arg ) = @_; if ( defined $arg ) { $self->{_data}->{$method} = $arg; } return $self->{_data}->{$method}; }; } else { croak qq%Can't locate object method $method via package % . __PA +CKAGE__ ; } goto &{$AUTOLOAD}; }

      /J\

Re: Re: Re: Whats wrong with symbol refs here?
by rdfield (Priest) on Feb 05, 2002 at 10:05 UTC
    If you were concerned about performance, you wouldn't be using OO, see perltoot.

    rdfield