Re: The dark corners of rep



Eli Barzilay <eli barzilay org> writes:
> * Even worse, `defvar' does its magic in a way that shadows possible
>   later definitions:
>
>     user> (defvar x 123)
>     x
>     user> (define x 1234)
>     user> x
>     123

That looks like a bug:
user> (let ((x 1234)) x)
1234
user> (let () (define x 1234) x)
123
Those two should be equivalent.  It seems to work if you don't use
defvar:
user> (define y 123)
user> (let () (define y 1234) y)
1234
It also works inside defines:
user> (define (foo) (let () (define x 1234) x))
user> (foo)
1234

>   which is of course not needed, because you can do the usual thing in
>   scheme:

Scheme also allows creating local bindings with define in the
beginning of the body of a lambda or let.

>   which happens because `define' is actually more like Lisp's `defvar'
>   and `defun' in that it has a global effect

Looks like another bug that only affects toplevel.  Inside defines
define seems to create local definitions as expected.

-- 
	Timo Korvola		<URL:http://www.iki.fi/tkorvola>


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