all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: okamsn+emacs-help@protonmail.com
To: help-gnu-emacs@gnu.org
Subject: Function value changes after running function?
Date: Fri, 05 Feb 2021 02:41:27 +0000	[thread overview]
Message-ID: <bad8f077-2af3-13a2-e7d8-297974798c1e@protonmail.com> (raw)

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	other threads:[~2021-02-05  2:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-05  2:41 okamsn+emacs-help [this message]
2021-02-05  3:16 ` Function value changes after running function? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bad8f077-2af3-13a2-e7d8-297974798c1e@protonmail.com \
    --to=okamsn+emacs-help@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.