In my experience object IDs almost always use the stringified reference as a hash key (the usual way for inside-out objects.) Or Scalar::Util::refaddr is used (as in Class::Std and PBP.)
refaddr returns the numified reference, but Scalar::Util already turns warnings off when munging that. (And SU does it in a rather bizarre way with a regex and hex instead of using direct numification for reasons that remain mysterious to me.)
I don't think there are many common uses of numified references outside those two contexts.
Update: Actually it looks like the issue with refaddr is fixed in recent versions. It uses int now. | [reply] [d/l] |
And SU does it in a rather bizarre way with a regex and hex instead of using direct numification for reasons that remain mysterious to me.
The answer to that is simple: overloading. Up until later perls (and even in them im not sure) there was no way to bypass overloaded nummification. Thus 0+$ref is inherently dangerous on a blessed ref. However there is and has always been a way to bypass overloaded stringification which conveniently contains the reference address in hex. Thus the only generally safe pureperl way to get the address of a ref is via this technique.
Having said that SU doesn't use the pure perl code except on older perl builds on OS'es/Machines that dont have XS installed. The XS code it uses for refaddr() is much more efficient and bypasses all of these problems.
---
$world=~s/war/peace/g
| [reply] |
Comparisons between objects. Depending on my mood, I'll use eq or == interchangably. Before we go ahead and do this, there needs to be considerable discussion. This will end up being a bigger change than expected.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |
| [reply] |
I don't think anyone was proposing that it be done without major discussion. I assume that the usual erudite discourse and flamewars to light up the night sky will take place on p5p. Personally, I think the change would be worth the effort.
| [reply] |