[plt-scheme] HTDP Section 22.1 some confusion...
>
>
> = (define f (local ((define (x-adder5 y) (+ 5 y))) x-adder5))
>>> ^? ^?
>>>now what I don't understand is where the 5 in x-adder5 comes from.
>>>There's nothing actually called x-adder5, right? that line could equally say
>>>= (define f (local ((define (add5please y) (+ 5 y))) add5please))
>>>It's not like you can call (x-adder5 20) is it? you can only invoke x-adder5 with (f x)
>>>x-adder5 is just there to show that the newly defined function has the formerly free variable x now fixed to 5
>>>please let me know If I've got this the right way round in my mozgy gulliver.
>
Yes, you got it right. The point is that free variables need to be
eliminated before the function can be lifted to the "global" level
where you would have:
(define (x-adder5 y) (+ 5 y))
(define f x-adder5)
As far as directly applying x-adder5 to an argument, the answer is
that you do not have access to it and therefore can not do so. Your
only way to use x-adder5 is via its other name, namely f. If you think
about it a little, the whole process is as simple as substituting
values to create functions that are specialized based on their free
variables.
--
Cheers,
Marco