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

Re: [PATCH pod/perlfunc.pod] ref can return false on references

Thread Previous | Thread Next
From:
Graham Barr
Date:
October 6, 2003 10:58
Subject:
Re: [PATCH pod/perlfunc.pod] ref can return false on references
Message ID:
A0AAA1BA-F826-11D7-B726-0003938857CC@pobox.com

On 6 Oct 2003, at 17:52, Gisle Aas wrote:

> Graham Barr <gbarr@pobox.com> writes:
>
>>>>    $ perl -wle 'print ref bless [] => 0'
>>>>    0
>>>
>>> I would be tempted to make that bless illegal.
>>
>> I dont see why we should treat that specially. People can always bless
>> into a package which has overload and have that return false.
>
> I don't think you are able to overload on the class name.  The HvNAME
> is just a char*.

I did not mean overload the package name itself, but rather

package False;

use overload bool => sub { 0 }

1;

Any reference blessed into that package will be false in a boolean 
context.

Graham.


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