Hi everyone, can someone help me understand what this problem is really about
and what the authors expect the reader to do?
Please help me I can't live without solving this problem.
I'm posting here the text for the probelm and for problem 3.26 too.
Unfortunately I skipped Exercise 3.26, I guess that's the only one I left out...
shame on me...
Exercise 3.42 [***] Modify the lexical address translator and interpreter to use the
trimmed representation of procedures from exercise 3.26. For this, you will need to
translate the body of the procedure not (extend-senv var senv),
[but in a new static environment that tells exactly where each variable will be kept in the trimmed
representation.] --> should I do something like (extend-senv var (empty-senv))???
Exercise 3.26 [**] In our data-structure representation of procedures, we have kept
the entire environment in the closure. But of course all we need are the bindings for
the free variables. Modify the representation of procedures to retain only the free
variables.
Here's a part of my lexical-address translator
;;translation-of : Exp × Senv ? Nameless-exp
(define translation-of
(lambda (exp senv)
(cases expression exp
...
(proc-exp (var body)
(nameless-proc-exp
(translation-of body
(extend-senv var senv)))) --> (extend-senv var (empty-senv))?
...
(else
(report-invalid-source-expression exp)))))
Let's take this as an example "let f = proc (x) -(x, 5) in (f 30)"
If I run the tranlator I get:
> (translation-of-program (scan&parse "let f = proc (x) -(x, 5) in (f 30)"))
#(struct:a-program
#(struct:nameless-let-exp
#(struct:nameless-proc-exp #(struct:diff-exp #(struct:nameless-var-exp (0 . 0)) #(struct:const-exp 5)))
#(struct:call-exp #(struct:nameless-var-exp (0 . 0)) #(struct:const-exp 30))))
The pair structure is for handling multimple arguments.
Is the lexical-address translator for problem 3.42 going to produce the same output?
What is the problem really asking?
Any suggestion is really welcomed.
Thank you,
Luca.
--
You received this message because you are subscribed to the Google Groups "EOPL3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/eopl3/-/4bIn_bw-cVkJ.
To post to this group, send email to eo...@googlegroups.com.
To unsubscribe from this group, send email to eopl3+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/eopl3?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/eopl3/-/poEoph1D-kEJ.