[Top][All Lists]

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

[Chicken-janitors] #1297: variables defined inside closure survive beyon

From: Chicken Trac
Subject: [Chicken-janitors] #1297: variables defined inside closure survive beyond closure!
Date: Thu, 09 Jun 2016 02:23:38 -0000

#1297: variables defined inside closure survive beyond closure!
 Reporter:  ai-artisan           |      Owner:
     Type:  change request       |     Status:  new
 Priority:  critical             |  Milestone:  someday
Component:  core libraries       |    Version:  4.11.0
 Keywords:  closure scope begin  |

 (require-extension r7rs)

 (define r #t)

 (define test (lambda ()
         (if r
                         (set! r #f)
                         (define v 123)
                         (display v)
                         (define v 234)


 ;; output: 234

 ;; The question is: Each time a procedure or partial block (like "let") is
 called, a closure should be created. Variables defined inside a closure
 should have a limited scope inside the closure unless "call/cc" or "call-
 with-values" is used. In the case above, none of them is used but the
 variable "v" survives beyond its closure created by "test" the 2nd time.

 ;; Further more, I found that only when "begin" is used will this bug

Ticket URL: <>
CHICKEN Scheme <>
CHICKEN Scheme is a compiler for the Scheme programming language.

reply via email to

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