On 2/25/07, Yuval Kogman <[EMAIL PROTECTED]> wrote:
On Sun, Feb 25, 2007 at 22:51:43 -0800, Joshua ben Jore wrote:
> On 2/25/07, Yuval Kogman <[EMAIL PROTECTED]> wrote:
> >Is there a function that is to this as overload::StrVal is to
> >stringification?
>
> No. blessed() doesn't lie to you and I don't change that. I didn't
> provide any ref-alike that provide the complete old behavior.

Hmm.... I usually do

        if ( ref $x ) {
                if ( my $class = blessed $x ) {

                } else {

                }
        }

Ick!!!! Neither ref nor blessed have never been a booleans before and
even this doesn't change that. Ref couldn't even used to decide if you
had an object because the two false values '' and '0' can both be
returned by objects:

 ok( ref( bless( ..., "\0" ) ), 'Detected object' ) # fails
 ok( ref( bless( ..., 0 ) ), 'Detected object' ) # fails

The only boolean you'll ever have on Perl 5 is defined( blessed( ... )
). It's a bad pattern to rely on ref(). Or... all '' and '0' using
classes were using UNIVERSAL::ref then... maybe... ref() could be
considered a boolean. I'd have to be convinced.

Incidentally, check out this madness. Instantly, all objects are invisible.

 package UNIVERSAL;
 use UNIVERSAL::ref;
 sub ref { return }

Wouldn't it be more
thorough to lie to blessed in the same way? People tend to use the
return value from ref and blessed as the class interchangiably once

I think blessed() ought to lie as well but not if the object itself
asks blessed() about itself. I thought it was out of my current scope
to mutate blessed() as well. Right now ref() will lie to anyone but
probably shouldn't lie to an object if it asks this of itself.

I haven't looked hard enough to see how to do scalar( caller() ) in XS yet.

Josh

Reply via email to