Version: 4.1

2.6 Output Printing Styles

Many Scheme languages support a Output Syntax choice that determines how evaluation results are printed in the interactions window. This setting also applies to output generated by calling print explicitly.

The following table illustrates the difference between the different output styles:

 

Input expression

 

Constructor

 

Quasiquote

 

write

 

(cons 1 2)

 

(cons 1 2)

 

`(1 . 2)

 

(1 . 2)

 

(list 1 2)

 

(list 1 2)

 

`(1 2)

 

(1 2)

 

'(1 2)

 

(list 1 2)

 

`(1 2)

 

(1 2)

 

(list (void))

 

(list (void))

 

`(,(void))

 

(#<void>)

 

`(,(void))

 

(list (void))

 

`(,(void))

 

(#<void>)

 

(vector 1 2 3)

 

(vector 1 2 3)

 

(vector 1 2 3)

 

#(1 2 3)

 

(box 1)

 

(box 1)

 

(box 1)

 

#&1

 

(lambda (x) x)

 

(lambda (a1) ...)

 

(lambda (a1) ...)

 

#<procedure>

 

'sym

 

'sym

 

'sym

 

sym

 

(make-s 1 2)

 

(make-s 1 2)

 

(make-s 1 2)

 

#(struct:s 1 2)

 

'()

 

empty

 

`()

 

()

 

add1

 

add1

 

add1

 

#<procedure:add1>

 

(delay 1)

 

(delay ...)

 

(delay ...)

 

#<promise>

 

(regexp "a")

 

(regexp "a")

 

(regexp "a")

 

#rx"a"

The Constructor output mode 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 empty list. Constructor output is especially valuable for beginning programmers, because output values look the same as input values.

The Quasiquote output mode is like Constructor output, but it uses quasiquote (abbreviated with `) to print lists, and it uses unquote (abbreviated with ,) to escape back to Constructor printing as needed. This mode provides the same benefit as Constructor output, in that printed results are expressions, but it is more convenient for many kinds of data, especially data that represents expressions.

The write output mode corresponds to traditional Scheme printing via the write procedure.

The current-print output mode, when available, prints results using the value of the current-print parameter, which allows the programming running in DrScheme to control its own output format.