guile-user
[Top][All Lists]
Advanced

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

Me no understand scoping


From: Maciek Godek
Subject: Me no understand scoping
Date: Tue, 29 Jul 2008 23:18:05 +0200

Hi,
consider the following code (simple iteration
construct invented mainly to cause naming
conflict, as the function 'times' is already
defined in guile)

(define-macro (times n f)
  `(let ((env (the-environment)))
     (let loop ((i 0))
       (if (< i ,n)
           (begin
             (local-eval ,f env)
             (loop (1+ i))
             )
           )
       )
     )
  )

the whole thing with env was made as
a workaround disallowing f to see the
i variable defined in the macro (and to
perhaps see the value that otherwise
would be shadowed)

however,

(times 20 (display i))

yields

012345678910111213141516171819

Why?

--
Regards
M.




reply via email to

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