Front page | perl.perl5.porters |
Postings from February 2012
Marking a XSUB as lvalue
Thread Next
From:
Father Chrysostomos
Date:
February 26, 2012 17:15
Subject:
Marking a XSUB as lvalue
Message ID:
949E2242-33F6-4EE0-82CA-9521992746E1@cpan.org
David Mertens wrote:
> On way to get rid of this issue, as far as I can tell, is to properly
> declare a few XSUBS as lvalue functions. (Right now they are improperly
> declared as such, if I read the above ticket correctly.) However, judging
> from this thread (
> http://www.nntp.perl.org/group/perl.perl5.porters/2009/08/msg149580.html),
> it looks like Perl does not support marking an XSUB as an lvalue sub. Is
> this correct? In particular, is there any way to do this that will stretch
> back to Perl 5.8, which is the version of Perl that PDL currently supports?
You should be able to use attributes.pm to apply the attribute to an
existing XSUB in any Perl version.
> A simple solution, I hope, would be to mark the subs as lvalue before
> calling Dynaloader. Would that work?
That would work, too.
However:
In CHM/PDL-2.4.10.tar.gz on CPAN, in the file Basic/Core/Core.pm.PL, on line 2240, I see this:
sub PDL::nslice {
And then the lvalue attribute is applied afterwards in Basic/Lvalue.pm. I don’t see an XS nslice anywhere. To solve that, apply the attribute before defining the perl function, either via ‘sub nslice:lvalue’ or ‘use attributes __PACKAGE__, \&nslice, "lvalue"’.
Which one of us is confused? Both?
Alternatively, you could persuade Ricardo Signes that it is OK for attributes.pm to turn on :lvalue on already-defined Perl subs, and I’ll back out the change, adding appropriate caveats to the docs.
I’m just uncertain what to do, due to lack of feedback.
Thread Next
-
Marking a XSUB as lvalue
by Father Chrysostomos