[plt-scheme] plai: lazyness and exercise 6.4.2

From: Aleix Conchillo Flaqué (aconchillo at gmail.com)
Date: Tue Aug 25 21:26:14 EDT 2009


I'm playing a bit with chapter 6 source code. While doing exercise
6.4.2 (explicit with) I found out that I was not able to use 'with'
for functions, that is:

{with {double {fun {x} {+ x x}}} {double 5}}

Then I also tried it with redundant with, and another problem arose,
as "aSub" second argument needs to be a FAE not a closureV, which is
what we get interpreting (interp arg-expr ds).

Using a lazy regime (exercise 6.6.1) we solve the issue for both cases
(we do not evaluate arg-expr nor named-expr), but of course, we need
to repeat things (I think chapter 8 solves this).

    [id (v) (interp (lookup-defrdsub v ds) ds)]
    [with (name named-expr body)
          (interp body (aSub name named-expr ds))]
    [app (fun-expr arg-expr)
         (let ([fun-val (interp fun-expr ds)])
           (interp (closureV-body fun-val)
                   (aSub (closureV-param fun-val)
                         (closureV-ds fun-val))))]

I tried to solve the problem with eager regime but I was getting a too
complicated code.

I'm not sure if that's the idea, so any comment or hint would be appreciated.

Best regards,


Posted on the users mailing list.