[previous] [up] [next]     [index]
Next: Input and Output Up: Printed Results Previous: Constructor-style Output

Quasiquote-style Output

Constructor-style output is inconvenient for printing S-expression results that represent programs. For example, the value '(lambda (x) (lambda (y) (+ x y))) prints as (list 'lambda (list 'x) (list 'lambda (list 'y) (list '+ 'x 'y)))

with constructor-style printing.

DrScheme's quasiquote-style output combines the input-output invariance of constructor-style printing with the S-expression readability of write. It uses quasiquote to print lists, and uses unquote to escape back to constructor style printing for non-lists and non-symbols.

With quasiquote-style printing, the above example prints as: `(lambda (x) (lambda (y) (+ x y)))

This example: (list 'lambda (list 'x) (box '(lambda (y) (+ x y))))

in quasiquote-style printing prints as: `(lambda (x) ,(box `(lambda (y) (+ x y))))


PLT