help-gnu-emacs
[Top][All Lists]
Advanced

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

Function value changes after running function?


From: okamsn+emacs-help
Subject: Function value changes after running function?
Date: Fri, 05 Feb 2021 02:41:27 +0000

Hello,

On Emacs 27.1, I've learned that a function using a macro I wrote raises 
an error after running the function a second time.

The function is

     (defun mu4e:other-path ()
       "Return load-path for mu4e.
     This assumes that you're on guix."
       (loopy (with (regexp "Documents")
               (base-dir (f-full "~/")))
         ((list file (directory-files base-dir))
          (expr full-path (f-expand file base-dir)))))

and running it once from my home directory returns nil, as expected. 
However, if run again, it raises an error

     ***  Symbol’s value as variable is void: base-dir

I've found after evaluating the function definition, `symbol-function' 
reports the definition as

     (closure
      (t)
      nil "Return load-path for mu4e.
     This assumes that you're on guix."
      (loopy
       (with
        (regexp "Documents")
        (base-dir
         (f-full "~/")))
       ((list file
              (directory-files base-dir))
        (expr full-path
              (f-expand file base-dir)))))

where `base-dir` is defined, but if I run it again, the function 
definition is reported again as

     (closure
      (t)
      nil "Return load-path for mu4e.
     This assumes that you're on guix."
      (loopy
       (with
        (regexp "Documents"))
       ((list file
              (directory-files base-dir))
        (expr full-path
              (f-expand file base-dir)))))

where `base-dir` is no longer defined.

Why would the function definition be changed after running the function? 
  Is that a known problem with macros, or with Emacs 27.1?  I haven't 
seen this on Emacs 28.

Thank you.




reply via email to

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