[prev in list] [next in list] [prev in thread] [next in thread] 

List:       racket-users
Subject:    [plt-scheme] HTDP Section 22.1 some confusion...
From:       morazanm () gmail ! com (Marco Morazan)
Date:       2009-04-30 12:42:28
Message-ID: 9b1fff280904300542x3c42fc0byf79080bfbf3d2f17 () mail ! gmail ! com
[Download RAW message or body]

> 
> 
> = (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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic