From leavens@cs.iastate.edu Thu Dec 6 16:53:40 2001 Date: Thu, 06 Dec 2001 13:45:21 -0600 From: Gary T. Leavens To: Aaron Forsyth Subject: Re: HW7, problem 3 Aaron, Aaron Forsyth wrote: > For problem 3, to display the error message, I used writeln and then returned 0 > as an expressed value. It seems to work just fine. Will I get points taken off > if I don't use the elop:error to display the error message like you did in your > example? It's not really an error then is it? I think you should use error or eopl:error. Sorry that makes testing harder, but the users shouldn't be allowed to continue as if nothing bad had happened... -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1040 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@cs.iastate.edu Sun Dec 9 23:07:29 2001 Date: Sun, 9 Dec 2001 23:05:14 -0600 (CST) From: Gary T. Leavens To: Aaron R Forsyth Cc: Computer Science 342 Staff Subject: Re: HW7 Prob 8 Aaron, On Sun, 9 Dec 2001, Aaron R Forsyth wrote: > I am getting the following error when I run the test with both the typed > and untyped checkers: > > Error: variable proctext is not bound. > > I think the problem is in the proctext-as-proc.scm file. This define uses a > cases statement for proctext but there is no define-datatype for proctext. > There is only a defrep for proctext. Right, so you can't use cases on a procedure. That would be for a AST rep, but you are programming a procedural rep. So don't use cases. > (define apply-proctext > (lambda (proc args env) > ;; > (cases proctext proc > (text (ids body) > (eval-expression body (extend-env ids args env)))) > )) > > Are we supposed to add a define datatype for proctext? No. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1040 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@cs.iastate.edu Fri Dec 21 08:36:32 2001 Date: Fri, 21 Dec 2001 08:35:27 -0600 (CST) From: Gary T. Leavens To: Daniel J Heck Cc: cs342s@cs.iastate.edu Subject: Re: Question about begin expressions? Dan, On Fri, 21 Dec 2001, Daniel J Heck wrote: > Hey all! > > I don't know if anyone will see this before exam time or even have time > to consider it, but here goes anyway: > > I am using the study guide to go through Section 3.7, and I copied over > and looked at the appropriate files. I'm confused as heck by the > implementation of "begin." If this was covered in class I missed it: > > (begin-exp (exp1 exps) > (let loop ((acc (eval-expression exp1 env)) > (exps exps)) > (if (null? exps) acc > (loop (eval-expression (car exps) env) (cdr exps))))) Yes, we never discussed this in class. This is a pretty odd corneer of the Scheme syntax, which allows you to write loops in this way. (Indeed, originally my type checker didn't handle this...) It defines loop to be a recursive procedure with two arguments, acc and exps, and the body of the loop procedure is the if expression; the initial values passed to acc and exps are given next to their declaration. Here's a translation into something we would normally write. (begin-exp (exp1 exps) (letrec ((loop (lambda (acc exps) (if (null? exps) acc (loop (eval-expression (car exps) env) (cdr exps)))))) (loop (eval-expression exp1 env) exps))) Does that make more sense? You can read more about this named let variant of Scheme in the Revised^5 Report on Scheme. Needless to say, you won't need to know that for the test. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1040 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580