all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: about "assignment to free variable"
Date: Tue, 05 Feb 2019 10:02:50 -0500	[thread overview]
Message-ID: <jwvd0o6s2o5.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: jwvmunabaw6.fsf-monnier+emacs@gnu.org

>> When i compile a piece of code the byte-compiler reports a warning
>> telling me that i'm trying to assign to a free variable:
>> But the variable in question is, atleast i think, referred to a local
>> variable because it is an argument of the function.
> I think your "at least I think" is in error.  But you'd have to show me
> the relevant code.

Looking at the current greader.el in your `master` branch, I suspect
you're talking about the warning

    In greader-change-backend:
    greader.el:203:18:Warning: assignment to free variable ‘backend’

where the problem is that this use of `backend` is within the
interactive spec: while the interactive spec is textually within the
definition of the function, it is code that's run outside of the
function (it's executed in order to build the list of arguments needed
to call the function).

So maybe the patch below would be the fix to this warning.


        Stefan


diff --git a/greader.el b/greader.el
index b854e0fa9..9491ac521 100644
--- a/greader.el
+++ b/greader.el
@@ -195,11 +195,12 @@ For example, if you specify a function that gets a sentence, you should specify
     (funcall greader-actual-backend command)))
 
 (defun greader-change-backend (&optional backend)
-  "changes back-end. if backend is specified, it changes to backend, else it cycles throwgh available back-ends."
+  "Change back-end.
+If BACKEND is specified, change to it, else cycle through available back-ends."
   (interactive
    (list
     (if current-prefix-arg
-	(setq backend (read-from-minibuffer "backend: ")))))
+	(read-from-minibuffer "backend: "))))
   (if (functionp backend)
       (if (memq backend greader-backends)
 	  (setq greader-actual-backend backend)




  reply	other threads:[~2019-02-05 15:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05  7:34 about "assignment to free variable" Michelangelo Rodriguez
2019-02-05 13:56 ` Stefan Monnier
2019-02-05 15:02   ` Stefan Monnier [this message]
2019-02-05 21:27     ` Michelangelo Rodriguez
2019-02-05 21:49       ` Stefan Monnier
2019-02-05 15:05   ` Michelangelo Rodriguez
2019-02-05 15:34     ` Michael Heerdegen

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=jwvd0o6s2o5.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@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.