Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: what definition of Istack_sp

by xiaoyafeng (Deacon)
on Jan 13, 2019 at 01:05 UTC ( [id://1228452]=note: print w/replies, xml ) Need Help??


in reply to Re: what definition of Istack_sp
in thread what definition of Istack_sp

Thanks! I've found statement in intrpvar.h: PERLVAR(I, stack_sp, SV **) /* top of the stack */ and in perl.h:
# define PERLVAR(prefix,var,type) type prefix##var; /* 'var' is an array of length 'n' */ # define PERLVARA(prefix,var,n,type) type prefix##var[n]; /* initialize 'var' to init' */ # define PERLVARI(prefix,var,type,init) type prefix##var; /* like PERLVARI, but make 'var' a const */ # define PERLVARIC(prefix,var,type,init) type prefix##var; struct interpreter { # include "intrpvar.h" };
So perl use PERLVAR to define perlinterpreter struct, it's strange to me, why is it not define perlinterpreter structure directly in perl.h? Please enlighten me.




I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re^3: what definition of Istack_sp
by dave_the_m (Monsignor) on Jan 13, 2019 at 11:26 UTC
    The perl binary has multiple ways in which it can be built. The simplest (and original) model just defines PL_stack_sp directly as a global variable. But when built with MULTIPLICITY (when for example building a threaded perl), then multiple interpreters are allowed, and (within the core), PL_stack_sp is defined as my_perl->Ispack_sp.

    However in XS code (rather than in the core), it's more complex. At one point PL_stack_sp was defined as a function call, which would shield the XS code from changes in the interpreter struct layout across differing perl versions - so XS modules wouldn't have be to recompiled for each new perl release. However, this slowed XS code down a lot, and there were other things which also broke binary compatibility, so that was ditched and we just changed the binary guarantee to apply only across minor releases.

    Dave.

      Thanks for your detailed answer! By the way, as your replied on this , 5.30 will add named parameter. I'm curious if it would affect current mechanism of argument stack which you mentioned above?




      I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

        Thanks for your detailed answer! By the way, as your replied on this , 5.30 will add named parameter. I'm curious if it would affect current mechanism of argument stack which you mentioned above?
        That's no longer likely to happen for 5.30: I ran out of time. Named sub parameters will only affect the sub itself, not the caller; and named args will only apply to perl subs, not to XS subs.

        Dave.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228452]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found