Data::Swap and ponie

[email protected] (Nicholas Clark) Mon, 11 Oct 2004 16:42:11 +0100
Newsgroups perl.ponie.dev
Message-ID <[email protected]>
I'm trying to build all of the modules used internally by Fotango with ponie.
I've hit on something I can't see how to fix easily. Data::Swap directly
references the insides of the SV head structure to do its job:

	any = r1->sv_any;
	flags = r1->sv_flags;
	r1->sv_any = r2->sv_any;
	r1->sv_flags = r2->sv_flags;
	r2->sv_any = any;
	r2->sv_flags = flags;


(see http://search.cpan.org/src/XMATH/Data-Swap-0.05/Swap.xs )


Right now it can be changed to the following, which will work:

        any = SvANY(foo);
        flags = SvFLAGS(foo);
        SvANY(foo) = SvANY(bar);
        SvFLAGS(foo) = SvFLAGS(bar);
        SvANY(bar) = any;
        SvFLAGS(bar) = flags;

but fairly soon I think it's going to become necessary for ponie to outlaw
assigning to SvFLAGS() and SvANY(), so I'm not sure where to go.

Should there be a new perl API function to perform this swapping function? As
I'm not sure how else it can be done cleanly in such a way as to continue to
work at all given the increased (and changing) abstraction that ponie will
provide/enforce.

Nicholas Clark