Stas Bekman <stas@stason.org> writes: >>>calls, XS modules and embedded applications which can pass the context >>>explicitly no longer have to call PERL_SET_CONTEXT at all! You get better >> >> >> XS modules already don't have to call PERL_SET_CONTEXT at all if you write >> them correctly (using PERL_NO_GET_CONTEXT, passing the context explicitly >> to pure C functions). Maybe this information should be published more >> prominently so that new modules take advantage of that. >> >> I'm not sure what "embedded" applications are. If you are talking about >> "embedding" applications (those who embed Perl interpreters vs. the other >> way round), then they will still have to juggle with PERL_SET_CONTEXT >> unless they can guarantee that the Perl code isn't using any modules, >> which seems unrealistic to me. > >Not really, they shouldn't if they create/clone the interpreters themselves. >like mod_perl 2.0 does. Look at this scary example: > >http://www.perldoc.com/perl5.8.0/pod/perlembed.html#Maintaining-multiple-interpreter-instances > > PERL_SET_CONTEXT(one_perl); > perl_construct(one_perl); > PERL_SET_CONTEXT(two_perl); > perl_construct(two_perl); > > PERL_SET_CONTEXT(one_perl); > perl_parse(one_perl, NULL, 3, one_args, (char **)NULL); > PERL_SET_CONTEXT(two_perl); > perl_parse(two_perl, NULL, 3, two_args, (char **)NULL); > > PERL_SET_CONTEXT(one_perl); > perl_run(one_perl); > PERL_SET_CONTEXT(two_perl); > perl_run(two_perl); > > PERL_SET_CONTEXT(one_perl); > perl_destruct(one_perl); > PERL_SET_CONTEXT(two_perl); > perl_destruct(two_perl); > > PERL_SET_CONTEXT(one_perl); > perl_free(one_perl); > PERL_SET_CONTEXT(two_perl); > perl_free(two_perl); > >This is just plain broken, because you already explicitly pass the context around. I agree with you here. These "major" heavyweight entry-points should do the PERL_SET_CONTEXT() for you. What gets messy is the lighter-weight entry-points e.g. Perl_get_sv() - if all those do PERL_SET_CONTEXT we will be slow, and if they don't and heavyweights do we need to distinguish the two classes.Thread Previous | Thread Next