John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

The file attributes.pm that comes with Perl 5.6.1 includes the line
BEGIN { bootstrap }
But there is no function bootstram anywhere in the file, nor any other use/import/whatever statements before this that might be producing it.

It's not a builtin listed in perlfunc.

So, what is it?

Ordinarily I'd think it was a bareword, which doesn't do anything. But the module works, so the internal functions (e.g. _modify_attrs) not defined in the .pm file must be getting loaded from somewhere, and that is the stated purpose of the call to bootstrap.

—John

Replies are listed 'Best First'.
Re: What is 'bootstrap'?
by rinceWind (Monsignor) on Nov 12, 2002 at 17:34 UTC
    Check out perldoc perlxstut and perldoc perlembed for information about what bootstrap does. Sriram Srivanam's book "Advanced Perl Programming" also goes into details.
(tye)Re: What is 'bootstrap'?
by tye (Sage) on Nov 12, 2002 at 19:22 UTC

    See xsutils.c (part of the source code to Perl itself), which includes a function XS_attributes_boostrap() which was probably produced using XS and then just cut'n'pasted into xsutils.c. Then see this code (in that same file):

    void Perl_boot_core_xsutils(pTHX) { char *file = __FILE__; newXS("attributes::bootstrap", XS_attributes_bootstrap, file +); }
    which defines *attributes::bootstrap to have a Perl code reference that calls the previously named C routine.

    BTW, this stuff (for modules that are bundled with Perl) is normally done by putting stuff in the ext subdirectory of the Perl source code tree. For example, see ext/attrs. I guess they didn't want to give people the ability to build Perl without including attributes.xs inside the base Perl run-time.

    Update: Yes, you've got it -- and other updates applied (inside bold parens).

            - tye
      So, the function attributes::bootstrap is linked into the perl executable, which is why there is no ext/auto files and this function doesn't need to be defined in the pm file.

      And, that's unusual. We expect it to be loaded dynamically and keep as much as possible out of the core.

      Have I got it?

      —John

Re: What is 'bootstrap'?
by pg (Canon) on Nov 12, 2002 at 17:09 UTC
    bootstrap is a part of DynaLoader. The function itself is the entry point for normal automatic dynamic loading.
Re: What is 'bootstrap'?
by perrin (Chancellor) on Nov 12, 2002 at 17:52 UTC
Re: What is 'bootstrap'?
by Mr. Muskrat (Canon) on Nov 12, 2002 at 17:04 UTC

    Okay, I am probably way off here but I am trying to learn.

    Could it be that DynaLoader.pm is coming into play and calling ExtUtils::Mkbootstrap to create the bootstrap?

    Update: After reading the other replies, I see that this must really be some deep Perl magic...

      But it's not use'ing DynaLoader first.