On 12/17/2013 02:51 PM, Christian Walde wrote: > On Tue, 17 Dec 2013 13:02:19 +0100, Zefram <zefram@fysh.org> wrote: > >> 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. > > After explaining in #p5p that outputs need to replace the inputs on the > stack, this all makes a lot more sense. > > Steffen, you probably want to mention this fact early on in your article > so the rest is more self-explanatory. :) Well that, and this discussion is a bit OT since the whole point is to show you what XS *does for you*. IOW I don't normally expect people to be fuzzing with sp (or SP or whatever) directly as much. Mentioning in the article that the output replaces input is indeed valuable, though. I'll try to remember for my way home! --SteffenThread Previous | Thread Next