Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

Where is the Nyquist Common Lisp Library?


Short answer - nowhere.

Rationale:

  1. XLISP is a very simple Lisp. Many of the XLISP functions are just simple wrappers around the underlying C functions. This makes XLISP, as an interpreted language, run with reasonable speed. The main advantage of XLISP over Common Lisp is that XLISP is much smaller and therefore much easier to learn.

  2. The main trick of Nyquist is to use XLISP only in the initial setup phase, where the Lisp code is parsed, to set-up the low-level sound sample functions, written in C, not in Lisp.

    The Nyquist low-level 'snd-...' functions only look like Lisp functions, but they are direct wrappers around C functions and behave like that. They do not provide type contagion, instead they expect a correct number of arguments, given in correct order with correct data types, and if not given exactly as expected, chances are good that Nyquist will crash.

    In Nyquist, XLISP [slow] is used to make sure that the low-level functions will be given the correct arguments, while the low-level sound sample functions after the initial setup phase will run in high-speed C, and not in Lisp anymore.

Because the Nyquist Common Lisp functions are running in interpreted XLISP, they run slower than the built-in XLISP functions. Because many Common Lisp functions do extensive parsing and/or type checking on their arguments, they run many times slower than XLISP. That's why overloading Nyquist with an extensive Common Lisp layer makes not much sense.

  Back to top


But why did you write so many Common Lisp functions?


I usually work with Common Lisp for prototyping, so if I'm porting code from Common Lisp to Nyquist:

  1. I first copy the Common Lisp code together with the respective Nyquist Common Lisp functions from screen into a Nyquist lisp file to see if the Common Lisp code works with Nyquist at all. Many of the Nyquist Common Lisp functions have argument tests to help with error tracking.

  2. When the Common Lisp code works with Nyquist I start to strip out everything I don't need for the particular problem at hand, making the Nyquist code run faster. Because this second step is highly depending on the particular problem at hand, there probably never will be a general solution for this.

I have tried to keep the functions as self-contained as possible, any dependencies to non-Nyquist functions are noted directly below the code.

There are many XLISP functions that behave exactly like their Common Lisp counterparts, so I haven't written extra functions for them.

In either case you can use the Nyquist Common Lisp functions as a grab-bag for your own functions.

  Back to top


Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference