all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Function value changes after running function?
@ 2021-02-05  2:41 okamsn+emacs-help
  2021-02-05  3:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-02-05 15:24 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: okamsn+emacs-help @ 2021-02-05  2:41 UTC (permalink / raw)
  To: help-gnu-emacs

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.




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

end of thread, other threads:[~2021-02-05 17:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-05  2:41 Function value changes after running function? okamsn+emacs-help
2021-02-05  3:16 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-05 15:34   ` okamsn+emacs-help
2021-02-05 15:48     ` Stefan Monnier
2021-02-05 17:27       ` Okam
2021-02-05 15:24 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.