On Mon, Oct 06, 2003 at 12:44:08PM -0700, schwern@pobox.com wrote: > On Mon, Oct 06, 2003 at 05:06:55PM +0100, Nick Ing-Simmons wrote: > > Abigail <abigail@abigail.nl> writes: > > >The first sentence of 'perldoc -f ref' is wrong: > > > > > > Returns a true value if EXPR is a reference, false otherwise. > > > > > >To wit: > > > > > > $ perl -wle 'print ref bless [] => 0' > > > 0 > > > > I would be tempted to make that bless illegal. > > I second that tempation. If the above is legal then this very common idiom > is no longer correct: > > print "$r is not a reference" unless ref $r; The blessing into the class '0' has been legal for as long as I can remember, and the code fragment you posted has always been incorrect. > And I'm not about to go around patching everything to say: > > print "$r is not a reference" unless length ref $r; > > just so someone can have their Acme module. It's not a matter of having an Acme module. It's a matter of how Perl has been working for a long time, and works right now. I don't like outlawing one specific value as the second argument to bless, that seems like a horrible kludge to me. If we could go back in time, I'd would 'ref' return 'undef' when its argument isn't a reference, but hindsight is always 20/20. If someone writes a patch to disallow blessing into the class '0', I wouldn't oppose it (and I guess the case is edgy enough it doesn't need a deprecation cycle), but until then, I think the documentation should be correct. And I'd think that 5.8.2 should just have the doc patch, not the bless patch to be. AbigailThread Previous | Thread Next