develooper Front page | perl.perl5.porters | Postings from October 2002

Re: [PATCH] lib/Tie/RefHash

Thread Previous | Thread Next
From:
Brian Ingerson
Date:
October 1, 2002 13:16
Subject:
Re: [PATCH] lib/Tie/RefHash
Message ID:
20021001131631.C23713@ttul.org
On 01/10/02 16:04 -0400, Benjamin Goldberg wrote:
> Brian Ingerson wrote:
> [big body of message]
> 
> Some parts of your suggestion don't sit well with me.

Good suggestions. This implementation was just thrown together to start
a more formal discussion of complex keys and the possibility of using
them in the default language. But thanks for the fixes.

Cheers, Brian

> 
> First:
> 
> +  # Blessed objects HASH themselves (see UNIVERSAL::HASH below)
> +  elsif ($k =~ /=/ and $k->can('HASH')) {
> +    $k->HASH();
> +  }
> 
> It does an unncessary stringification of $k here, and it uses the ->can
> method (which may have been overridden to do something funky).
> 
>    # Blessed objects HASH themselves (see UNIVERSAL::HASH below)
>    elsif( UNIVERSAL::can($k, 'HASH') ) {
>      $k->HASH();
>    }
> 
> Which avoids action-at-a-distance from stringification or ->can().
> 
> Next:
> 
> +  # Else just use *identity*
> +  else {
> +    "$k";
> +  }
> 
> If $k overloads '""', this isn't exactly identity.
> 
>    # Else just use *identity*
>    else {
>      $INC{'overload.pm'} ? overload::StrVal($k) : "$k";
>    }
> 
> (Which fails if something does overloading without first loading
> overload.pm, which possible but unlikely).
> 
> -- 
> How many Monks would a Chipmonk chip,
> if a Chipmonk could chip Monks?

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About