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


I know I'm an idiot for not understanding the nuances of scoping et al,

I have something like:

(when (find-menu "Foobar") (menu-deinstall (find-menu "Foobar")))

(defparameter foobar (make-instance 'menu :menu-title "Foobar"))
(apply #'add-menu-items foobar
  (let ((activities #(A B C))
        (items nil)
    ;(declare (<WHAT GOES HERE?!!!> activity)
    (dotimes (i (length activities) (nreverse items))
      (setq activity (aref activities i))
        (make-instance 'menu-item
          :menu-item-title (string activity)
          #'(lambda ()
              (print activity)))

(menu-install foobar)


This results in a list of menu-items, each with the correct title, but the
functions all affect the LAST activity, rather than the ith.  ie, All of
the menu-items print C.

I understand that the variable activity is incorrectly scoped, but what do
I do to fix it?

-- "TANSTAAFL" Rich lynch@ils.nwu.edu