[previous] [up] [next]     [contents] [index]
Next: Libraries Up: Language Reference Previous: MrEd Toolbox

Printer

    DrScheme's contructors style printer treats cons, vector, and similar primitives as value constructors, rather than functions. It also treats list as shorthand for multiple cons's ending with the null list. So, when values are printed, they look different from usual scheme implementations. This table details all of the differences between MzScheme's and DrScheme's printed values.

tabular1131

DrScheme's printer can be confusing if you are accostomed to the traditional Scheme printer--but if you look at complicated values in MzScheme, for example: (1 2 dog (4 . 5) #((1 . 2) 3)) you would see: (list 1 2 'dog (cons 4 5) (vector (cons 1 2) 3))

in DrScheme, and the structure of the value is transparent.

However, the printer is not as useful if you are working with s-expression as scheme code. For example, the value '(lambda (x) (lambda (y) (+ x y))) will print as

(lambda (x) (lambda (y) (+ x y)))

in MzScheme, but will print as

(list 'lambda (list 'x) (list 'lambda (list 'y) (list '+ 'x 'y)))

in DrScheme. For those programs, you should use the Quasiquote style printer. That printer uses quasiquote to print lists, and uses unquote to escape back to constructor style printing for non-lists, and non-symbols. The above example prints as: `(lambda (x) (lambda (y) (+ x y)))


PLT