develooper Front page | perl.perl5.porters | Postings from December 2013

Re: An article on writing Perl extensions without XS

Thread Previous | Thread Next
December 17, 2013 12:02
Re: An article on writing Perl extensions without XS
Message ID:
Christian Walde wrote:
>I do think that, instead of forcing people to do `sp -= items;` just
>to be able to iterate forwards through arguments with ++, someone
>would probably have instead just made a macro that points to the
>start of the arguments in the stack.

This is one of the things that arises from efficiency concerns.
You could replace sp[3] (used after sp-=items) with sp[3-items] (with no
decrement of sp), but it's a more complex expression, which depending
on CPU architecture may take longer to execute.  (It'll be the same on
current x86 CPUs.)  The decrement also gets you into the right place to
start pushing return values.  Decrementing sp is part of the stereotyped
variable use that you'd likely reinvent, at least for variadic xsubs.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About