On Monday, July 22, 2002, at 04:22  AM, Elizabeth Mattijsen wrote:
> You should therefore _always_ check the validity of the first value 
> passed to DESTROY and make sure it is what you expect it to be.  If you 
> don't, you're looking at indeterminate (strange) execution errors or 
> segfaults.
>
> The check could be as simple as:
>
>   return if ref($_[0]) ne 'your::class::name';
>
> Please note that you cannot use the isa() method, as you may not be 
> dealing with an object anymore at this stage.  So this makes it tough 
> for sub-classes.  So maybe:
>
>   return unless ref($_[0]);

I usually just call UNIVERSAL::isa($_[0], 'your::class::name') in these 
cases.


  -Ken

Reply via email to