previous up next     contents index
Next: Evaluation Rules Up: Donkey's Scheme Previous: Call/cc

Sharing

    Donkey can annotate the shared structure in an expression. Donkey always uses this mechanism to display circular structures ; for other structures the facility may be turned on or off in the Options Menu (Section 4.3). Sharing is expressed with the following syntax:

(shared ((-id1- expr1)
         (-id2- expr2)
         ...)
  expr3)

where the exprs may contain references to the ids. For example, the value produced by evaluating

  (define a (list 1 2 3)) (list a (cdr a) (cddr a))

would normally be displayed as

  (list (list 1 2 3) (list 2 3) (list 3))

but with sharing it produces

  (shared ((-1- (cons 2 -2-))
           (-2- (list 3)))
    (list (cons 1 -1-) -1- -2-))

For a similar example of sharing see Figure 1.