| OCR Text |
Show APPENDIX E ACRE USER DEFINED EXTENSIONS This appendix describes how to extend the ACRE language. Native C code is at least 100 times faster than ACRE code, so computation intensive ACRE routines may be converted to C to speed up program execution. The first example illustrates a user-defined function that returns a double. The second example function returns a string, and the third illustrates a database transactions with more user control. All extensions to the ACRE language take the form of functions that take one or more arrays of doubles as arguments. At most 1 0 arguments are passed in an argument array. The first entry has the count of arguments, and the second serves as a switch into the set of user defined functions. This leaves eight useful arguments to pass to a function. If more are required, then a change is required in the code of the function extend() in the file pars.C. There is a single entry point to each type of function, and the first type has the form: ACRE_extend(<function>, <args>*). The C extension file can be recompiled without recompiling the rest of ACRE, but the executable does need to be relinked. Making an extension simply requires that a developer put a new case in the ACRE_extend function listed below. To make an extension to an ACRE program that performs the addition of parallel resistance, the following code would be added to the ACRE source. |