[plt-scheme] Defining structures

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Feb 17 21:34:41 EST 2009

On Feb 17, 2009, at 9:21 PM, aditya shukla wrote:

> So in other words can i say that define-struct will define the data  
> type and (define phonebook (make-entry 'PeterLee 15270 '606-7771))  
> would create a variable named phonebook of the data type entry?

1. Variables don't have types in Scheme. Values have "dynamic types"  
aka type tags.

So this particular variable is a placeholder for a value whose tag is  
"entry".


2. A structure and a type don't necessarily coincide (in any language  
that is halfway decent). Take a look:

(define-struct dress (layer neath))

;; An RD is one of:
;; -- 'naked
;; -- (make-dress Symbol RD)

If you want to call anything a "type" here, it is RD.

-- Matthias



Posted on the users mailing list.