Hi,
By "numeric flags", I'm referring to the "IOK", "pIOK", "NOK", "pNOK" and the "IsUV" flags (as presented by Devel::Peek::Dump).
But rather than have this information displayed, I'm looking for a sub that returns the status of these specific flags. That is, something like:
sub flag_status {
my $v = $_[0];
return is_IOK($v) | is_pIOK($v) | is_IsUV($v)
| is_NOK($v) | is_pNOK($v);
}
sub is_IOK {
# return 1 if argument's IOK flag is set
# else return 0
}
sub is_pIOK {
# return 2 if argument's pIOK flag is set
# else return 0
}
sub is_NOK {
# return 4 if argument's NOK flag is set
# else return 0
}
sub is_pNOK {
# return 8 if argument's pNOK flag is set
# else return 0
}
sub is_IsUV {
# return 16 if argument's IsUV flag is set
# else return 0
}
The aim is to be able to determine whether a subroutine call changes the status of any of those flags on the subroutine's argument. That is:
my $d = 2.7;
my $flags_prior = flag_status($d);
foo($d);
my $flags_after = flag_status($d);
die "foo() altered its argument's numeric flags"
if($flags_prior != $flags_after);
Is there already a perl module that ships with the core that will return the status of those 5 flags ?
Is there already a module on CPAN that will return the status of those 5 flags ?
I know how to find the status of "IOK", "NOK" and "IsUV" in XS.
One can merely test the truth of SvIOK(sv), SvNOK(sv) and SvUOK(sv) respectively.
But how does one establish, in XS, whether the "pIOK" and "pNOK" flags are set ?
Maybe there's another way to approach this.
The key thing is that I want to be able to
programmatically catch the occurrence of foo() altering its argument's "numeric flags".
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.