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 { } } in code that tries to be very duck friendly. 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 they're sure the thing is an object, and they probably use both to find out if it is an object. This could lead to some very puzzling bugs (especially if UNIVERSAL::ref is being used by some 3rd party code, the worst kind of action at a distance). > If you read t/basic.t file, you'll see a few things marked as TODO. It > isn't omniscient yet. Its a 0.01 release and probably deserves that. Does this imply blessed() will lie in the future too? > Data::Lazy uses this how....? Curiously, I would bet this would let > ref( $obj ) return undef which normally ref() never does. There's also > the names with \0 in them somewhere. Normally you can't ever bless > into something with a \0 in it (its just a C string). You could... > have objects that tell that they're something with a \0 in it. You > could even return another object. Heh. Oops, wrong lazy module... http://search.cpan.org/~audreyt/Scalar-Defer-0.07/ Scalar::Defer blesses into '0' to pretend that the value is not a ref in the case of: if ( ref $scalar ) { } even though $scalar is an object with all overloads in effect. It's basically trying to be the mother of all proxies. I suppose if the value at the end of the thunk turns out to be an object it probably reblesses itself, or it could even use Data::Swap to really become that referant (?)... this is purely conjectural though since I am actually sleeping. > I think I'm going to be telling Devel::Spy to go use this now too. > That aims to be a transparent proxy. Si, same theme ;-) -- Yuval Kogman <[EMAIL PROTECTED]> http://nothingmuch.woobling.org 0xEBD27418
pgpaepv3O23As.pgp
Description: PGP signature