## 4 Embedding Compiled Routines Inside Yorick ¶

You can create a custom version of Yorick containing your own C or Fortran compiled code. If you are careful, your custom version will be easily portable to any site where Yorick has been installed. You will considerably ease portability problems (read “future hassles for yourself”) by writing in ANSI C, which is a portable language, as opposed to Fortran, which is not.

My experience with C++ is that its portability is intermediate between ANSI C and Fortran. You should be able to write C++ packages for Yorick by using the `extern "C"` statement for the interface routines called by the interpreter. I don’t encourage this, however, since the interpreted language removes many of the motives for programming in C++ in the first place.

If you do choose Fortran, stick to a strict subset of ANSI Fortran 77. Do not attempt to pass character variables into or out of interface routines, nor put them in common blocks. Also, try not to use common blocks to pass inputs to or receive outputs from your interface routines. (This is possible; if you enjoy Fortran programming, presumably you’ll enjoy figuring out a portable way to do this.)

Whether you write in Fortran or C, do not attempt to do I/O of any sort in your compiled code. The whole idea of embedding routines inside Yorick is to let Yorick handle all I/O – text and graphics. Another way to say this is, that you want the interface between the interpreted and compiled code to be arrays of numbers. Let the interpreter handle reading text to produce the input arrays, or writing graphics to display the output arrays.