Subject: | not modify readonly scalars |
Date: | Tue, 19 Jan 2010 09:02:48 +1100 |
To: | bug-File-Map [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
If map_file() is given a readonly scalar I think it should refuse to
change the value, so as to protect scalars intended to be constants,
making a program like readonly.pl below get an error. I think it would
be as easy as
if (SvREADONLY(var))
Perl_croak(aTHX_ Perl_get_no_modify(aTHX));
(If I understand the Perl_get_no_modify() func being meant for
portability to ms-dos where cross-library variables don't work, or
something like that. The function form is new in perl 5.005 or some
such, but could be a candidate for ppport.h if earlier was wanted.)
Protecting readonlys also has the happy effect of preventing `undef' or
similar specials accidentally getting modified when prototypes are not
in effect, per undef.pl below.
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.