Speed is not completely irrelevant for the task at hand. That's antoher reason why I'm reluctant to try copy everything back and forth and like the idea of just blessing a reference to a pointer. Also, the C library actaully does have methods for almost everything, so there's very little API use for actually having wrapper Per blessed-hash objects. to manage stuff.
But let me ask the question another way:
What does the Perl interpreter guarantee about dual value objects? Is there any official guarantee of semantics?
I Mean... Scalar::Util even advertises the use of dualvar() to set both an interger and a string value on a scalar. So some guarantees must be provided.
If the guarantee is to alway copy and preserve the entire struct SV and struct xpvmg... and in general support multi-valued vars (PV,IV,NV) ...and.. hmm.. NV being the same size as IV, then there should be nothing wrong with the approach.
| [reply] [Watch: Dir/Any] |
Not thinking so much of “blessed” anythings. Instead, thinking of the exchange of (say, a “person”) consisting of a hash-type variable ... which might, say, include a “_personid” element provided by the library and which contains the moniker I spoke of. Basically, you would be shifting data between C structures and hashes ... a lot ... if you pursued my suggestion. Which, I will very freely admit, absolutely might not be the right thing for you to do in your case! (I was wrong once ... lessee, how many years ago was it, now? Or am I wrong about that ...?) ;-)
As far as I know, the dual-value feature is basically there in the name of efficiency, so that you can have '123' and 123 at the same time. But I am not qualified to answer your question about interpreter guarantees or the lack thereof.
| [reply] [Watch: Dir/Any] |
As far as I know, the dual-value feature is basically there in the name of efficiency, so that you can have '123' and 123 at the same time. But I am not qualified to answer your question about interpreter guarantees or the lack thereof.
Having dual values IV/PV is not so rare a use case. One example is error-codes. Many modules provide the error message in string context and the integer error code when using int().
I also just found an example of PV/NV duality
What my suggestion did was IV/NV duality. But with the little twist that the SVf_NOK flag was not set. It was for internal usage of back-referencing the owning object only. ... Who's using that NV slot anyway?
| [reply] [Watch: Dir/Any] |