Node:Lisp support, Next:, Previous:System interface, Up:Top



Lisp support

An expression in Lisp/Scheme syntax may entered by prefixing it with the Scheme keyword. The expression is read using a programmable Lisp reader. Then the resulting Lisp object is converted to a Q expression for evaluation.

Q1> print_readable:=1
Q2> Scheme (quote (:foo #(3 4 5)))
['foo [3 4 5]]

To print an object in Lisp/Scheme syntax, set the print_lisp variable:

Q3> print_lisp:=1
Q4> Scheme '(:foo #(3 4 5)))
(:foo #(3 4 5))

The only special form that has been implemented is quote, so the Scheme keyword has limited usefulness. A number of issues also need to be resolved, such as the representation of the empty list/sequence (Scheme 'nil vs. Scheme '() vs. []).

A number of functions from Common Lisp and the Scheme R3 report have been implemented. You can use them in Q code:

Q5> Scheme (symbol->string 'abc)
"abc"
Q6> (Lisp #'find-package) "common-lisp"
package "common-lisp"

Right now, you can also just name Lisp function directly in Q code, since Scheme, Lisp, and Q use the same global name space. This will probably change:

Q7> symbol\-\>string 'abc
"abc"
Note that -> had to be "quoted" with \s.

The following Common Lisp functions and values have been implemented: car, cdr, cddr, cadr, cons lispread (calls the Lisp reader) nil, t vector integer-length getprop, putprop, remprop, symbol-plist, symbol-package make-symbol find-package symbol-function, symbol-value, set, boundp, fboundp, makunbound, fmakunbound

The following Scheme functions have been implemented: car, cdr, cddr, cadr, cons vector, make-vector, vector-fill! symbol->string, string->symbol

The only recognized declare form is a non-standard one: (declare (external Foo)) in the body of a function declares that when the function is compiled, the name of the emitted C++ function should be Foo. (declare (external "Foo")) is the same, except that it declares that the assembler label of the function is Foo. If the there are no forms in the function following a (declare (external ...)) form then the function is assumed to be defined in some external C++ file. See C interface.