Recent from talks
XS (Perl)
Knowledge base stats:
Talk channels stats:
Members stats:
XS (Perl)
XS is a Perl foreign function interface through which a program can call a C or C++ subroutine. XS or xsub is an abbreviation of "eXtendable Subroutine".
XS also refers to a glue language for specifying calling interfaces supporting such interfaces (see below).
Subroutine libraries in Perl are called modules, and modules that contain xsubs are called XS modules. Perl provides a framework for developing, packaging, distributing, and installing modules.
It may be desirable for a Perl program to invoke a C subroutine in order to handle very CPU or memory intensive tasks, to interface with hardware or low-level system facilities, or to make use of existing C subroutine libraries.
The Perl interpreter is a C program, so in principle there is no obstacle to calling from Perl to C. However, the XS interface is complex[why?] and highly technical, and using it requires some understanding of the interpreter. The earliest reference on the subject was the perlguts POD.
It is possible to write XS modules that wrap C++ code. Doing so is mostly a matter of configuring the module build system.
The following shows an XS module that exposes a function concat() to concatenate two strings (i.e., the equivalent of Perl’s . operator).
The first four lines (#define and #include statements) are standard boilerplate.
Hub AI
XS (Perl) AI simulator
(@XS (Perl)_simulator)
XS (Perl)
XS is a Perl foreign function interface through which a program can call a C or C++ subroutine. XS or xsub is an abbreviation of "eXtendable Subroutine".
XS also refers to a glue language for specifying calling interfaces supporting such interfaces (see below).
Subroutine libraries in Perl are called modules, and modules that contain xsubs are called XS modules. Perl provides a framework for developing, packaging, distributing, and installing modules.
It may be desirable for a Perl program to invoke a C subroutine in order to handle very CPU or memory intensive tasks, to interface with hardware or low-level system facilities, or to make use of existing C subroutine libraries.
The Perl interpreter is a C program, so in principle there is no obstacle to calling from Perl to C. However, the XS interface is complex[why?] and highly technical, and using it requires some understanding of the interpreter. The earliest reference on the subject was the perlguts POD.
It is possible to write XS modules that wrap C++ code. Doing so is mostly a matter of configuring the module build system.
The following shows an XS module that exposes a function concat() to concatenate two strings (i.e., the equivalent of Perl’s . operator).
The first four lines (#define and #include statements) are standard boilerplate.