<div dir="ltr"><p>Is this the general practice? It looks rather cumbersome and difficult to plan for.<br></p>
<p>Is there anything that would prevent me from having to wrap functions in make-parameter calls? Something like Clojure's binding special form (if you're familiar with it).</p><p>- Cristian<br></p>
<div class="gmail_quote">On Dec 21, 2012 6:45 PM, "David Van Horn" <<a href="mailto:dvanhorn@ccs.neu.edu" target="_blank">dvanhorn@ccs.neu.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 12/21/12 9:41 PM, Cristian Esquivias wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm trying to replace a function with another using parameterize.<br>
<br>
For example, when I try:<br>
<br>
(define (add2 n)<br>
(add1 (add1 n)))<br>
<br>
(parameterize ([add1 (ë [n] (+ n 2))])<br>
(add2 2))<br>
<br>
I get an error:<br>
<br>
parameterize: contract violation<br>
expected: parameter?<br>
received: #<procedure:add1><br>
<br>
How do I re-bind functions in Racket?<br>
</blockquote>
<br>
You can only use parameterize with names bound to parameter values. Here's an example:<br>
<br>
#lang racket<br>
(define padd1 (make-parameter add1))<br>
<br>
((padd1) 4)<br>
<br>
(parameterize ([padd1 (ë (n) (+ 2 n))])<br>
((padd1) 4))<br>
<br>
David<br>
<br>
<br>
</blockquote></div>
</div>