[racket] Code Error Creating List

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue May 17 23:07:44 EDT 2011

Todd D: 

1. This code must be the worst formatted Racket code I have seen in a long time. Please read EOPL and follow its example. 

2. Next, when DrRacket tells you that a particular sub-expression in your program raised an error, please -- pretty please -- pay attention. I removed the superfluous parts of your program, added the one-line ddt, ran free-vars-list on a simple var-exp and immediately got the correct highlighting: 

#lang eopl 

(define-datatype expression expression? (var-exp (id symbol?)))

(define free-vars-list
  (lambda (body)
    ( ;; <<================================== pink starts 
     (if (list? body) 
         (append (free-vars-list (car body)) (free-vars-list (cdr body)))
         (cases expression body
           ;; When we have a var-exp, return the variable
           (var-exp (id) id)
           (else (list 'fvl "can't happen")))
         )
     )
    ) ;; <<================================= pink ends 
  )

(free-vars-list (var-exp 'x))


3. What are these parens doing here? Let me rewrite this here: 

(define free-vars-list 
  (lambda (body) 
    (  (if (list? body) ... ...) ) 
  )
) 

[I sincerely apologize for the last two lines.] 

As you can see now, your if expression is the function position of an application. Why? 






Posted on the users mailing list.