in reply to PerlHack - Adding new flag into a SV
[11:44:57] gmpassos: Yes, but I also can't change the SV of the user!
[11:45:01] broquaint: bart: correct re DBI having magic
[11:45:30] bart: If you're allowed to use it for whatever you like, than other people can too, and there's no guarantee these two won't clash.
[11:45:58] gmpassos: The user will paste to me any type of SV (HV, AV...), I just need to mark it, but I can't change it since I can break some behavior
[11:47:00] gmpassos: bart, in Perl we always can do everything, we can't start to discuss in this area! ;-P
[11:47:39] broquaint: gmpassos: shouldn't you be storing a reference of some kind to what is pasted to you instead of marking it? it seems a bit of an odd approach ...
[11:47:55] gmpassos: broquaint, if I add a magic to a SV, I change the SV or create a new SV from it?
[11:48:14] bart: You won't get a blessing from P5P, I'm sure. And those are the people who decide.
[11:48:39] gmpassos: broquaint Actually the main idea is to not store a reference. Read the last text blopck of the node...
[11:49:36] broquaint: aah (just read the rest of the node), just store the pointer bit i.e push @ptrs, ref($thing) =~ /\(([a-z0-9]+)\)$/; and then use something like Devel::Pointer to access it again
[11:49:43] gmpassos: bart I don't need to change Perl to add a new flag.
[11:49:44] bart: A weak reference?
[11:50:32] gmpassos: broquaint Now read the 2nd block (Why use a flag) ;-P
[11:50:44] bart: You don't? How can you be sure then what you're doing won't clash with what perl does itself, in future versions?
[11:52:19] gmpassos: bart This is why I'm asking if exists some reserved range. The only thing that I can guarantee is to check if it wasn't broken in the future
[11:52:54] bart: Anyway, there's also the option that perl has simply destroyed the SV, without telling you.
[11:53:09] broquaint: gmpassos: then use a weak reference (a la Scalar::Util's weaken) as bart suggested
[11:54:15] bart: So... what does DBI's "magic" do?
[11:56:13] gmpassos: weaken?
[11:56:45] gmpassos: where I can read about a weaken reference
[11:56:52] broquaint: gmpassos: you *could* take the magic route as you can always add magic to magic, but that seems somewhat dangerous and *can* change the behaviour of the SV
[11:57:47] broquaint: gmpassos: in the Scalar::Util documentation? what it does is decreases the refcnt of the thing that holds the reference so what it points to will get cleaned up correctly
[11:58:04] bart: WeakRef, later absorbed into Scalar::Utils
[12:03:31] gmpassos: Well, I think that weak ref is just what I need! thanks!~But I need to know if this will work in my tests! eeheheh
Time passes while tests are fiddled and fixed
[12:53:37] gmpassos: broquaint With wek references is just working wonderful! thanks for the adviceThere you have it, conclusive proof that the CB is more than just a meeting room.
[13:00:05] broquaint: np gmpassos, reckon I should post a reply?
[13:00:58] gmpassos: broquaint Will be nice, just to end the thread and keep what we have talked on CB.
[13:01:03] bart: Well, somebody should.
[13:01:52] gmpassos: broquaint All my tests and the tests of the 2 modules that use Hash::NoRef are ok now. And I 'don't need to change anything! heeh!
[13:02:29] gmpassos: Well, I have added at least an update
[13:02:33] broquaint: nice one, gmpassos. I'll do a quick post now (should I include CB chatter?)
[13:03:09] gmpassos: To what you think that you have to do! 8-P
[13:03:26] gmpassos: s/to/do/i
_________
broquaint
|
|---|