in reply to Re^2: redefining Internals::SvREADONLY
in thread redefining Internals::SvREADONLY
"Other"? Ah, I didn't realize Internals::SvREADONLY could. Yes, it just exports SvREADONLY_on(sv) and SvREADONLY_off(sv) to Perl land.
It sounds like you are trying to prevent someone from preventing you from making variables read-only. All I pointed out that it's moot since they can undo your work should you manage to get it done.
But you know what, one doesn't even need to make the variable not readonly to change it. The READONLY flag is purely advisory. It can simply be ignored.
use strict; use warnings; use Inline C => <<'__EOI__'; void change_it(SV* sv) { SvIV_set(sv, 789); SvIOK_only(sv); } __EOI__ my $i = 123; Internals::SvREADONLY($i, 1); print("$i\n"); eval { $i = 456; }; print("$i\n"); change_it($i); print("$i\n");
123 123 789
Update: Added realisation that READONLY if advisory.
|
|---|