chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] parameterize


From: Felix
Subject: Re: [Chicken-users] parameterize
Date: Thu, 06 Jan 2011 14:20:19 +0100 (CET)

From: Joo ChurlSoo <address@hidden>
Subject: [Chicken-users] parameterize
Date: Thu, 06 Jan 2011 20:39:24 +0900

> 
> The following parameterize behavior seems to be wrong.
> 
> CHICKEN
> (c)2008-2010 The Chicken Team
> (c)2000-2007 Felix L. Winkelmann
> Version 4.6.0 
> linux-unix-gnu-x86 [ manyargs dload ptables ]
> compiled 2010-12-31 on INITERM (Linux)
> 
> #;1> 
> (define a (make-parameter 1))
> (define b (make-parameter 2 number->string))
> 
> #;2> #;3> (list (a) (b))
> (1 "2")
> #;4> (parameterize ((a 10) (b 20)) (list (a) (b)))
> 
> Error: (number->string) bad argument type: "2"
> 

This is interesting. If you expand a `parameterize' form, you get:

#;5> ,x (parameterize ((x 99)) 1)
(##core#let
  ((g110 x) (g112 99))
  (##core#let
    ((swap (##core#lambda
             ()
             (##core#let ((t (g110))) (g110 g112) (##core#set! g112 t)))))
    (##sys#dynamic-wind swap (##core#lambda () 1) swap)))

As can be seen here, the old value is retrieved, stored in a lexically
bound variable, the parameter is changed to contain the new value
(including processing by the guard procedure (`number->string' in this
case) and after execution of the body, the parameter is restored to
the old value. The guard procedure will be re-invoked for the restored
value, which is a bug. Thanks for reporting this.


cheers,
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]