EOPL 3.42

177 views
Skip to first unread message

Luca

unread,
Nov 27, 2012, 7:10:06 AM11/27/12
to eo...@googlegroups.com

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.

Mitchell Wand

unread,
Nov 28, 2012, 11:42:04 AM11/28/12
to eopl3
If you didn't do 3.26, you have no hope of doing 3.42.   And make sure that you can do more complicated examples, like

let x = 3 y = 4 z = 5
in let f = proc (u v) -(-(u,x),-(v,z))
in (f 30)


--
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.

Luca

unread,
Nov 29, 2012, 4:41:21 PM11/29/12
to eo...@googlegroups.com
What sort of a help is that?

"You'll never solve this"

I did solve all the exercises for the first three chapters but two or three (among which 3.26) and that was not a problem.

I can do examples like this:
> (run "let x = 3 y = 4 z = 5
in let f = proc (u, v) -(-(u,x),-(v,z))
in (f 30 25)")
#(struct:num-val 7)

Mitchell Wand

unread,
Nov 29, 2012, 4:46:47 PM11/29/12
to eopl3
That's an important help.  When you do 3.26, you will learn what you need in order to do 3.42.



To view this discussion on the web visit https://groups.google.com/d/msg/eopl3/-/poEoph1D-kEJ.
Reply all
Reply to author
Forward
0 new messages