Deprecating SvPVX/marking it readonly

[email protected] (Arthur Bergman)
Newsgroups perl.perl5.porters,perl.ponie.dev
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.