|P is for Practical|
In Perl, take two references to the same variable. Bless one. Note that the other reference is now blessed. Conclude that the blessed state is stored in the referenced variable not in the reference (not that surprising).
I proved it to myself by blessing a reference in Perl then passing it to dump_sv. My question is "why?"
The semantic difference is exactly what you said -- the blessing is shared by all references to the value. But I still don't understand why those semantics are more useful than the alternative. I'm not claiming that it should be the other way around, just that I personally don't know the reason why it is one way and not the other.
Thinking through it, I realize that if it were the other way around (blessed references were actually blessed references), then you could have the same data item with multiple references pointing to it, each blessed with a different package. If each of them defines a DESTROY, which DESTROY should get called? Or more to the point, when should DESTROY be called? The way it is now (blessed referents), DESTROY is called when the last reference to the data item goes away, which makes a lot of sense. If references were blessed, then you would have to call DESTROY whenever any of the references themselves went away, which would result in multiple DESTROYs getting called for the same data item (each with a different package). And destroying references isn't really that interesting anyway (they don't really have any data to diddle with); destroying the data item is.
Ok, maybe I do understand the "why?", now.
In reply to Re^3: Inline::C-Cookbook's "Object Oriented Inline" (bless'd ref)