in reply to Re^2: perl interpreter must be named my_perl?
in thread perl interpreter must be named my_perl?

Yeah - if you want to use a different variable name, you have to avoid all the macros. I'm not sure if there is a simple way to recognize all those macros (beyond running the compiler). As aTHX and aTHX_ are known, then likely any macro that contains THX (the thread handle, if Perl is compiled with threads, empty otherwise) should be avoided...

Replies are listed 'Best First'.
Re^4: perl interpreter must be named my_perl?
by ikegami (Patriarch) on Dec 01, 2023 at 03:49 UTC

    No, that's all wrong. The THX macros don't care about the name of the "top-level" variable.

    aTHX should only be used in a function which either has pTHX in its parameter list or in which dTHX; is used. In a MULTIPLICITY build, aTHX will only access the parameter var named my_perl created by pTHX or the local var named my_perl created by dTHX. In other words, it only accesses the my_perl variable the THX macros create themselves.

    In a non-MULTIPLICITY build, those macros are all undefined. They don't mention my_perl at all.

    So either way, they don't care about the name of the name of the "top-level" variable.

      In a non-MULTIPLICITY build, those macros are all undefined. They don't mention my_perl

      But MULTIPLICITY is the de facto default build option, Am I right?

        Just to be clear, I said the global my_perl isn't used by the THX macros with or without MUTLIPLICITY.

        As for MULTIPLICITY being the default? No. It's is off by default.

        MULTIPLICITY is what allows a process to have multiple interpreters. A build with thread support requires MULTIPLICITY since each thread has its own interpreter. So MULTIPLICITY is automatically defined when a building Perl with thread support.

        A build without thread support usually won't use MULTIPLICITY. If the OP's program only needs one interpreter, they should use a build of Perl that was built without MULTIPLICITY (for a performance boost).

        I would avoid words like "de facto, default" and just do my own checks:

        linux perlbrew:

        perl -V | grep -i multi usemultiplicity=undef

        linux system perl:

        usemultiplicity=define Compile-time options: ... MULTIPLICITY

        I liked Multiplicity - what the heck is it?

        bw, bliako