develooper Front page | perl.perl5.porters | Postings from October 2003

Deprecating SvPVX/marking it readonly

Thread Next
From:
Arthur Bergman
Date:
October 27, 2003 05:33
Subject:
Deprecating SvPVX/marking it readonly
Message ID:
156F2418-0882-11D8-AC29-000A95A2734C@nanisky.com
Hi,

For the future with parrot/ponie and other exciting stuff like copy on 
write I would like to propose an internal deprecation or change of SvPVX

        SvPVX   Returns a pointer to the physical string in the
                SV.  The SV must contain a string.

                        char*   SvPVX(SV* sv)


Currently, this means that you are allowed to take a the char, and 
change it (as long as you don't change the length), however it is 
already not a safe operation to do since the char* might contain 
unicode characters (so any code that uses this without checking for 
utf8 is broken).

With COW the problem is that as soon as you do SvPVX we need to break 
copy on write since there is no way we know if the sv might change, For 
the parrot/ponie layer we need to do tricker by returning a temporary c 
string and pushing a function on the destructor stack so we can later 
check if the string has been changed and then assign it. (Yes this is a 
kludge).

So I propose we either

a) deprecate it and provide something else for getting the raw string, 
preferably something that you can use with unicode

b) document it to be a read only function

c) document it to be a read only function and export a char* copy

c) document it to be a read only function and export something that 
supports unicode

Arthur


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About