[Bioperl-l] Re: issues with _rearrange

Aaron J Mackey Aaron J. Mackey" <amackey@virginia.edu
Fri, 20 Sep 2002 11:09:34 -0400 (EDT)


On Fri, 20 Sep 2002, Aaron J Mackey wrote:

> There's two, orthogonal issues at stake here:
>
> 1) Ability of the _rearrange method to handle multiple styles of
> arguments; as Matthew and others have suggested, we could break this into
> a few different methods, specific for each style; this would accelerate
> the _rearrange calls by essentially stripping it of unused code for each
> type of style.

I realized in re-reading Matthew's email, that I misinterpreted what he
meant (to paraphrase and recast a bit):

$self->new(-arg1 => $a1, -arg2 => $a2);

would be:

sub new { return shift->new_fast(_rearrange(@_)); }

sub new_fast {
  ($self, $a1, $a2) = @_;
  # real new() functionality here ...
}

and then code that wanted to bypass _rearrange, could just call new_fast
directly:

$self->new_fast($a1, $a2);

If we didn't want to have to know the required order of params we might
use:

$self->new_notasfast(arg2 => $a2, arg1 => $a1);

sub new_notasfast {
  my ($self, %params) = @_;
  return $self->new(@params{qw(arg1 arg2)});
}

Alternatively, you could also imagine that the new() code remained in
new(), but that new() would be caller()-savvy and send it's params off to
_rearrange unless it saw that it was getting called via new_fast() or
whatnot.

This discussion needs some "elder"-level wisdom I think ...

-Aaron