Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the autobox CPAN distribution.

Report information
The Basics
Id: 55670
Status: resolved
Priority: 0/
Queue: autobox

People
Owner: CHOCOLATE [...] cpan.org
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: 42->isa("UNIVERSAL") is false
autobox 2.60 causes 42->isa("UNIVERSAL") to return false. autoboxed objects do respond to UNIVERSAL methods. $ perl -wle 'use autobox; sub UNIVERSAL::echo { print "@_" } print "Yes" if 42->isa("UNIVERSAL"); 42->echo' 42 This may not be possible given my previous request to allow $class->isa and $class->can to work, but I figured I'd report it for discussion.
It's the "correct" result given that autobox method calls are effectively syntactical sugar for: class($native)->can($method)->($native, ...) i.e. in this case: UNIVERSAL::isa(42, 'UNIVERSAL') # undef Making it throw a - Can't call method "isa" without a package or object reference - error for UNIVERSAL methods as though autobox is disabled is misleading and inconsistent. What if the user has defined e.g. SCALAR::isa? Should we ignore it? Doing magic so that UNIVERSAL method calls are diverted to method calls on the class does the wrong thing in the case of string invocants as per RT #55565. What do you suggest?
Subject: Re: [rt.cpan.org #55670] 42->isa("UNIVERSAL") is false
Date: Thu, 18 Mar 2010 20:03:11 -0700
To: bug-autobox [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
chocolateboy via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=55670 > > > It's the "correct" result given that autobox method calls are > effectively syntactical sugar for: > > class($native)->can($method)->($native, ...) > > i.e. in this case: > > UNIVERSAL::isa(42, 'UNIVERSAL') # undef > > Making it throw a - > > Can't call method "isa" without a package or object reference > > - error for UNIVERSAL methods as though autobox is disabled is > misleading and inconsistent. What if the user has defined e.g. > SCALAR::isa? Should we ignore it? Doing magic so that UNIVERSAL method > calls are diverted to method calls on the class does the wrong thing in > the case of string invocants as per RT #55565. > > What do you suggest?
I think, given the ambiguity, this is fine. Especially once I figured out that it's normal isa behavior rather than something in autobox. autobox COULD get clever and say "this can't possibly be a class name so we'll assume you mean to ask isa() of the autoboxed object" but the hell with it. I'm happy to say "$thing->isa() always means $class->isa()" and avoid the ambiguity. I can't say I'm not going to think this is a bad idea a week from now. Seriously playing with autoboxing dredges up all sorts of weird edge cases. Anyhow, it can be resolved. I just wanted to get your opinion. -- 52. Not allowed to yell "Take that Cobra" at the rifle range. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/