[plt-scheme] The perfect teaching language--Is this too much to ask for?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Jun 14 13:02:08 EDT 2009

Todd and Marco, for your reading pleasure I have translated this  
student's program into DeinProgram (ISL, basically): see end of message.

I will say the results surprised me in two ways:

-- At first I ran the program as given, and got an error about  
APPEND, not a contract error concerning names. In other words, the  
Run stops at the exact same place as the Run of the original program  
in ISL. 

-- Then I commented out the second unit test case to find out how  
DeinProgram would react now. Surprise again. It told me that the test  
case had passed AND that the contract had failed. 

(I will let you figure out why both behaviors surprise me.)

Working with the program has also clarified how I would go about this  
pedagogically, with what exists now, and in the future. I'll post  
these thoughts separately. -- Matthias


;; A family-tree-node (ftn) is:
;; empty, or
;; (make-ftn ftn ftn symbol number symbol)
(define-record-procedures ftn make-ftn ftn? (ftn-father ftn-mother  
ftn-name ftn-dob ftn-eyes))

(define Carl (make-ftn empty empty "Carl" 1926 "green"))
(define Bettina (make-ftn empty empty "Bettina" 1926 "green"))
(define Adam (make-ftn Carl Bettina "Adam" 1950 "yellow"))
(define Dave (make-ftn Carl Bettina "Dave" 1955 "black"))
(define Eva (make-ftn Carl Bettina "Eva" 1965 "blue"))
(define Fred (make-ftn empty empty "Fred" 1966 "pink"))
(define Gustav (make-ftn Fred Eva "Gustav" 1988 "brown"))


(: names (ftn -> (List string)))
;; consumes: a ftn
;; produces: a list of all names of people reachable
;;           from that ftn
(define names
   (lambda (a-ftn)
     (cond
       [(empty? a-ftn) ""]
       [(ftn? a-ftn) (append (names (ftn-father a-ftn))
                             (names (ftn-mother a-ftn))
                             (list (ftn-name a-ftn)))])))

(check-expect (names empty) "")
;(check-expect (names Adam) (list "Carl" "Bettina" "Adam"))


Posted on the users mailing list.