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 mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to