Skip to content
Felix S. Klock II edited this page Jul 28, 2013 · 1 revision

pass3 produces the following code:

7

when run on either of the following expressions:

((lambda (x y) (+ x y)) 3 4) ((lambda (x y) (((lambda (x) x) +) x y)) 3 4)

But it generates this:

(let ((.f|2 +)) (.f|2 3 4))

for any of the following:

((lambda (f x y) (f x y)) + 3 4) ((lambda () ((lambda (f) (f 3 4)) +))) ((lambda (f) (f 3 4)) +)

I'm quite puzzled as to what the distinction is here.

  • SamTh

The optimizer doesn't want to inline variables that appear in the procedure call position? What does the following give you?

((lambda (f) (f f)) (lambda (x) x))

Of course, this may not help since the passed-in value isn't a primop.

Even doing

((lambda (f) (f f)) +)

which will obviously be nonsense when run results in

(let ((.f|1 +)) (.f|1 .f|1))

so I assume an instance of a variable being used as a procedure keeps it from being inlined.

Ha, but doing this:

((lambda (f) (f f)) 3)

results in this:

(let ((.T2 3)) (.T2 3))

so now it replaces it in the argument position but not the function call position.

  • StevieS
Clone this wiki locally