Question

At what point are function names bound in Racket?

At what point are function names bound in Racket?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note:-

We have seen one kind of name already: the formal parameters used in lambda expressions. These are a special type of name and are bound to values when the function is called. In this subsection, we’ll look at using names more generally. Unlike the imperative programming languages we are used so far, names in (pure) functional programming represent immutable values – once we are bound them to a particular value (or function, because remember functions are values) you can’t change them.

(define z 10)

(define (make-z-adder) (lambda (x) (+ x z)))

(define add-z (make-z-adder))

> (add-z 5) 5

15

The body of make-z-adder is a function with a free name z, which is bound to the global z

(let ([z 100])

((make-z-adder) 5))

Now the lambda expression is evaluated after we call the function in the local scope, but what value of z gets saved in the closure? The value used is the one bound to the name that is in the scope where the lambda expression is in the source code.

Add a comment
Know the answer?
Add Answer to:
At what point are function names bound in Racket?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT