I'm working on a module that need to add a new flag to a SV that is stored by it. Actually I just need to find a way to mark that SV by this module, so, will be possible to identify this SVs from the others.
*Why use a flag?
Because if I just use the number of a SV and its type, I can't guarantee that is the same SV that I have stored, since Perl can reuse that SV after clean it. If I just use the type and the number is possible that until the next access to this SV, that SV was actually destroied, than a new SV can be created with the same type and number. So, adding a flag I can guarantee that it wasn't cleanned until that, since when a SV is cleanned its flag is reseted.
I need to know if someone already done something like that, and if you, all the developers that hack Perl internals, think that this is the best way to do that, and if it is, if this is a secure thing to do.
Also I need to know if exits some reserved range for external flags defined in Perl, since I can't use a number for the flag that is in use, or any range that can be in use in the future.
*Why do that?
Is for the module Hash::NoRef, where I need to store a value/object without actually make a reference to it. I previously tried to store a reference value and decrement its REFCNT, but this will create a lot of problems, including CORE dump of the interpreter, specially if we try to access this value after the destruction of it, since is impossible to know if a reference was destroied when the REFCNT is artificialy changed, and also we can access a recycled SV. As a new approach I will store the type and number of the SV, and mark that SV to guarantee that it wasn't destroied. After this I can access the SV getting it directly from the list of SVs in use.
Thanks in advance and wish me luck! ;-P
UPDATE:
Resolved with weak references. Thanks to broquaint and bart that helped in the CB.
Graciliano M. P.
"Creativity is the expression of the liberty".
In reply to PerlHack - Adding new flag into a SV by gmpassos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |