[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Weird scope of variable defined inside cond
From: |
Vítor De Araújo |
Subject: |
[Chicken-users] Weird scope of variable defined inside cond |
Date: |
Tue, 12 May 2015 02:44:30 -0300 |
Hello!
I'm seeing some weird behavior regarding scope of a variable defined
with 'define' inside a cond clause. For instance:
(define (foo x)
(define bar 23)
(cond [(number? x)
(define baz 42)
(list baz)]
[else 'whatever]))
(foo 3)
(print baz) ; prints 42!
(print bar) ; unbound variable, as expected
Additionally, if I type the above definition of 'foo' directly in csi,
I get a message:
Note: the following toplevel variables are referenced but unbound:
baz (in foo)
Is this a bug, or I'm missing something? I'm running Chicken 4.9.0.1 on
Debian GNU/Linux x86-64. I also tried it with the version from the git
repository and got the same result.
Thanks in advance!
--
Vítor De Araújo
http://inf.ufrgs.br/~vbuaraujo
- [Chicken-users] Weird scope of variable defined inside cond,
Vítor De Araújo <=