No subject

From: ()
Date: Mon Dec 3 19:58:15 EST 2012

bindings created with binding can be assigned to, which provides a
means for a nested context to communicate with code before it on the
call stack. This capability is opt-in only by setting a metadata tag
:dynamic to true as in the code block above






On Sat, Dec 22, 2012 at 4:23 AM, Cristian Esquivias
<cristian.esquivias at gmail.com> wrote:
> Is this the general practice? It looks rather cumbersome and difficult to
> plan for.
>
>
> - Cristian
>
> On Dec 21, 2012 6:45 PM, "David Van Horn" <dvanhorn at ccs.neu.edu> wrote:
>>
>> On 12/21/12 9:41 PM, Cristian Esquivias wrote:
>>>
>>> I'm trying to replace a function with another using parameterize.
>>>
>>> For example, when I try:
>>>
>>> (define (add2 n)
>>>    (add1 (add1 n)))
>>>
>>> (parameterize ([add1 (ë [n] (+ n 2))])
>>>    (add2 2))
>>>
>>> I get an error:
>>>
>>>   parameterize: contract violation
>>>    expected: parameter?
>>>    received: #<procedure:add1>
>>>
>>> How do I re-bind functions in Racket?
>>
>>
>> You can only use parameterize with names bound to parameter values. Here's
>> an example:
>>
>> #lang racket
>> (define padd1 (make-parameter add1))
>>
>> ((padd1) 4)
>>
>> (parameterize ([padd1 (ë (n) (+ 2 n))])
>>   ((padd1) 4))
>>
>> David
>>
>>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>


Posted on the users mailing list.