On Mon, Oct 06, 2003 at 10:26:20PM +0200, Rafael Garcia-Suarez wrote: > > 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. > > What about making C<ref bless [], 0> return "main::0" ? It's a true value > and it's a correct package name. And with that the documentation can > be restored to its previous state if you like. Now the class "0" becomes even more of a special case. ref() doesn't behave that way for anything else. Imagine some code trying to figure out if a ref is of a given type, where the type might be "0". sub is_type { my($ref, $type) = @_; $type = "main::0" if $type eq "0"; print "Yes" if ref $ref eq $type; } Ugg. And that solution breaks backwards compat anyway because this no longer works. $o = bless {}, "0"; print "Yes" if ref $o eq "0"; 0 but true values are so problematic in Perl 5 we should avoid them wherever possible. Fortunately, in this case, while its always been possible to have an object of class "0" in Perl, its only been noticed now. I'd rack this up as a "discovered feature" rather than backwards compatibility. If it was a true backwards compat problem, someone would have run afoul of all the C<"not a ref" unless ref $foo> code out there already and reported it. Also, from a maintenance standpoint, its orders of magnitude more work to correct all the code out there which is doing C<"not a reference" unless ref $foo> rather than fix the few odd bits of code that might be using class "0".Thread Previous | Thread Next