[previous] [up] [next]     [contents]
Next: Pragmatics of define-struct Up: Intermezzo 1: Structures Previous: Syntax of define-struct

Semantics of define-struct

The define-struct form adds a new class of values to DrScheme, instead of defining values constructed with lists, and it introduces a new shorthand for printing those values. Thus, if you define the c structure with

(define-struct c (s1 s2))

and then type (make-c 1 #t) in the interactions window, DrScheme replies with (make-c 1 #t). In contrast, when you define make-c directly with
(define (make-c s1 s2) (cons s1 (cons s2 empty)))

and then type (make-c 1 #t) in the interactions window, DrScheme replies with (cons 1 (cons #t empty)).



PLT