Compiling SPL Functions


To become active, SPL functions must be loaded into DADiSP. When you type or otherwise specify the routine myfun(), DADiSP performs the following steps:


  1. If myfun is a macro, perform macro substitution and continue processing.

  2. If myfun is a built in function, run the function.

  3. If myfun is an SPL function already loaded into memory, run the function

  4. If myfun.spl exists, load and compile myfun.spl and try running the function myfun.


Thus, if myfun is an SPL function saved in the file myfun.spl, it is automatically loaded into memory when first needed.


If SPL_AUTO_LOAD is set to 2 in DADiSP.cnf, DADiSP will always attempt to load the file myfun.spl even if myfun is an SPL function already loaded into memory. This mode is very useful when developing SPL routines.


SPL functions can be loaded directly. Select SPL, Read SPL File from the Tools pull-down menu to read an SPL file. From the command line, splread reads an SPL source file directly and if there are no syntax errors, loads the functions into the DADiSP environment. However, once a program file is working properly, the splload function creates a compiled version of the SPL file with extension .opl and loads the file much faster. For example, the command splload("myfun") or splload myfun works as follows:


  1. Because no extension was specified, splload first attempts to read the file myfun.opl, a compiled version of the file myfun.spl.

  2. If myfun.opl does not exist, splload attempts to compile the function myfun.spl to create and load myfun.opl.

  3. If both myfun.opl and myfun.spl exist, splload recompiles myfun.spl if its file date is newer than myfun.opl, otherwise myfun.opl is loaded directly.


The splload function can also be invoked in the more concise "command" form:


 splload myfun


The splcompile function compiles an SPL file, creating the corresponding .opl file without loading the functions into the DADiSP environment.


Although .opl files are very efficient low level representations of the corresponding .spl program files, SPL files are not compiled into the machine language of a particular computer platform.