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

Re: An article on writing Perl extensions without XS

Thread Previous | Thread Next
From:
Zefram
Date:
December 17, 2013 12:02
Subject:
Re: An article on writing Perl extensions without XS
Message ID:
20131217120219.GL21945@fysh.org
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.

-zefram

Thread Previous | 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