unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Me no understand scoping
@ 2008-07-29 21:18 Maciek Godek
  2008-07-30  3:24 ` Clinton Ebadi
  0 siblings, 1 reply; 23+ messages in thread
From: Maciek Godek @ 2008-07-29 21:18 UTC (permalink / raw)
  To: guile-user

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.




^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2008-09-11 14:56 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cmu-lmtpd-29005-1217434291-0@mail-imap1.uio.no>
2008-07-30 16:18 ` Me no understand scoping Kjetil S. Matheussen
2008-07-30 19:03   ` Clinton Ebadi
2008-07-29 21:18 Maciek Godek
2008-07-30  3:24 ` Clinton Ebadi
2008-07-30  8:42   ` Maciek Godek
2008-07-30 14:03     ` Jon Wilson
2008-07-30 15:04       ` Klaus Schilling
2008-07-30 19:24       ` Maciek Godek
2008-07-31  7:20         ` Neil Jerram
2008-07-31 19:21           ` Maciek Godek
2008-07-31 21:37             ` Neil Jerram
2008-07-31 23:07               ` Maciek Godek
2008-08-02 17:43                 ` Neil Jerram
2008-08-02 21:36                   ` Maciek Godek
2008-08-08 20:54                     ` Neil Jerram
2008-08-10 21:49                       ` Maciek Godek
2008-08-09 11:05                     ` Andy Wingo
2008-08-10 22:30                       ` Maciek Godek
2008-09-11 14:56                       ` JonWilson
2008-07-31 23:48             ` Clinton Ebadi
2008-08-01 22:00               ` Maciek Godek
2008-08-02  5:13                 ` Jon Wilson
2008-08-02 21:35                   ` Maciek Godek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).