[Bioperl-l] attribute setting and return value

Hilmar Lapp hlapp@gnf.org
Sun, 29 Sep 2002 17:17:39 -0700


Correct. The problem with this is that then we need to very 
carefully review code and instruct new module developers that the 
following is an absolute no-no:

	sub mymethod {
	    my ($self,$value) = @_;
	    # this call only delegates to another method (alias) or to
	    # an inherited method or a composition delegate
	    return $self->othermethod($value); # gotcha! potentially 
sets to undef!
	}

This pattern is in some parts abundant, because the bioperl.lisp 
method body starts off with this ($self,$value) thing. I've hit this 
before and I'd like to spare others from tracking this down once it 
you see values you know you've set mysteriously mutating to undef.

	-hilmar
	
On Sunday, September 29, 2002, at 06:11 AM, Aaron J Mackey wrote:

>
> I think Tim typo'ed and meant "can't set an attribute to undef"; his
> version allows it, while most of our others don't.
>
> -Aaron
>
> On Sun, 29 Sep 2002, Ewan Birney wrote:
>
>> On Sun, 29 Sep 2002, Tim Bunce wrote:
>>
>>> Another problem with both styles shown is that you can set an 
>>> attribute to undef.
>>> Here's an alternative to the first style (it's also faster):
>>
>> Quite often you want to be able to set an attribute to undef to 
>> indicate
>> absence.
>
>
--
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------