[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 |
---------------------------------+---------------------
;;debug.scm
(require-extension r7rs)
(define r #t)
(define test (lambda ()
(if r
(begin
(set! r #f)
(define v 123)
(test)
(display v)
(newline)
)
(begin
(define v 234)
)
)
))
(test)
;; 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
appear.
--
Ticket URL: <http://bugs.call-cc.org/ticket/1297>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.
- [Chicken-janitors] #1297: variables defined inside closure survive beyond closure!,
Chicken Trac <=