Unexpected behavior with loop macro and closures

前端 未结 2 1344
星月不相逢
星月不相逢 2020-12-18 10:49

Why do these forms behave this way?

CL-USER>
(setf *closures*
      (loop for num in (list 1 2 3 4)
            collect (lambda ()
                      n         


        
2条回答
  •  独厮守ぢ
    2020-12-18 11:13

    The name num represents the same binding during the evaluation of LOOP. Maybe you want to write:

    (mapcar 'constantly (list 1 2 3 4))
    

    to get what you meant.

提交回复
热议问题