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:
Gisle Aas
Date:
October 6, 2003 11:39
Subject:
Re: [PATCH pod/perlfunc.pod] ref can return false on references
Message ID:
lr7k3i8b69.fsf@caliper.activestate.com
Graham Barr <gbarr@pobox.com> writes:

> 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.

Sure.  But since that does not make ref(bless [], "False") false so I
don't see how this is relevant to whether bless $something, "0" should
be allowed.

Regards,
Gisle

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