> <\body> \; In order to glue C++ functions in the interpretor, the steps are needed: <\enumerate-numeric> Write files which define the correspondance between the functions and the functions. Generate \ files from the files using , to define the glue functions. Compile the generated files to build the dynamic library to be loaded in the interpretor.\ The files for the correspondance between the mathemagix functions and the external functions in the interpretor are put in the folder . Here is a first example. <\mmx-code> require "basix/glue_double.mmx"; \; foreign cpp import { \ \ cpp_include "my_fct.hpp"; \ \ \ \ f : Double \ -\ Double == my_fct;\ } In this example, the function of the interpretor uses the function\ <\cpp-code> double my_fct(double) declared in the file . A important rule to keep in mind is the following: <\quotation> > In our example, the inclusion of the file defines the required specialization for the type , so that the fonction will be defined.\ Here is a second example:\ <\mmx-code> foreign cpp import { \ \ cpp_preamble /" \ \ \ \ \ using namespace std; \ \ \ \ \ inline double make_tropical(double x) {return x;} \ \ "/; \ \ class Tropical == double; \ \ tropical : Tropical \ -\ Tropical == make_tropical;\ \ \ infix +: (Tropical, Tropical) -\ Tropical == max; \ \ infix *: (Tropical, Tropical) -\ Tropical == infix +; } specialize Tropical; \ We define a new type in the interpretor, which is implemented in C++ as . We define a function which corresponds to the C++ function and operators corresponding to and corresponding to the C++ operator . \ The function is defined in the preamble part which will copied verbatim in the generated glue file. The instruction is needed to generate the glue for all these functions. These functions can be used in the as follows: <\mmx-code> a: Tropical := tropical(2.2); b: Tropical := tropical(0.1); a+b; a*b; \; In the next example, we glue template functions: <\mmx-code> include "basix/categories.mmx require "basix/glue_int.mmx"; require "basix/glue_double.mmx"; \; foreign cpp import { \ \ cpp_preamble /"using namespace std;"/; \ \ cpp_include "dual_number.hpp"; \ \ \ \ forall(C: Class) { \ \ \ \ class Dual C == pair C; \ \ \ \ dual : (C,C) -\ Dual C == pair C;\ \ \ } \ \ \ \ forall(C: Ring) {\ \ \ \ \ infix +: (Dual C, Dual C) \ -\ Dual C == dual_add; \ \ \ \ infix *: (Dual C, Dual C) \ -\ Dual C == dual_mul ; \ \ }\ \ \ \ \ forall(C: Field) { \ \ \ \ infix /: (Dual C, Dual C) \ -\ Dual C == dual_div ; \ \ } } \; specialize Dual Int; specialize Dual Double; In this example, the parameterised type of dual numbers is implemented as C\>. The constructor is valid for any type of coefficients , but the operators and are glued only if is a ring (here for and ) whereas the link of the operator is valid is is a field (here for ). The glue of these functions is generated throught the instructions \ Supose that the name of the package is . By convention, the glue files which provide specialization should be put \ in the folder . Then running <\shell-code> mmxglue in the folder will generate the corresponding glue files in the folder . The will be uptable. To generate the dynamic library which can be uploaded in the interpretor, the following command can be run: <\shell-code> cmake ../pkg -DGLUE=ON && make The library (,) will be compiled in the local folder and can be loaded with <\mmx-code> use "tropical"; \; . If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.>