* about "assignment to free variable"
@ 2019-02-05 7:34 Michelangelo Rodriguez
2019-02-05 13:56 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Michelangelo Rodriguez @ 2019-02-05 7:34 UTC (permalink / raw)
To: emacs-devel
Hi All,
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.
So, what it means exactly?
The code works fine even if compiled.
If it is necessary i can post the code, even if it is large.
Thanks for your replies and best regards.
Michelangelo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: about "assignment to free variable"
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
2019-02-05 15:05 ` Michelangelo Rodriguez
0 siblings, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2019-02-05 13:56 UTC (permalink / raw)
To: emacs-devel
> 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.
"*free* variable" doesn't mean "a variable which will not exist when this
code is run" but "a variable which is not visible in the surrounding scope".
> The code works fine even if compiled.
Until it doesn't.
> If it is necessary i can post the code, even if it is large.
Pointing me to the relevant file+linenb should be sufficient.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: about "assignment to free variable"
2019-02-05 13:56 ` Stefan Monnier
@ 2019-02-05 15:02 ` Stefan Monnier
2019-02-05 21:27 ` Michelangelo Rodriguez
2019-02-05 15:05 ` Michelangelo Rodriguez
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2019-02-05 15:02 UTC (permalink / raw)
To: emacs-devel
>> 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)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: about "assignment to free variable"
2019-02-05 13:56 ` Stefan Monnier
2019-02-05 15:02 ` Stefan Monnier
@ 2019-02-05 15:05 ` Michelangelo Rodriguez
2019-02-05 15:34 ` Michael Heerdegen
1 sibling, 1 reply; 7+ messages in thread
From: Michelangelo Rodriguez @ 2019-02-05 15:05 UTC (permalink / raw)
To: emacs-devel
Hi Stefan,
The file is greader.el, fetched from gitlab.
The warning is at line 203, at least the line reported by the compiler.
Thanks in advance.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: about "assignment to free variable"
2019-02-05 15:05 ` Michelangelo Rodriguez
@ 2019-02-05 15:34 ` Michael Heerdegen
0 siblings, 0 replies; 7+ messages in thread
From: Michael Heerdegen @ 2019-02-05 15:34 UTC (permalink / raw)
To: Michelangelo Rodriguez; +Cc: emacs-devel
Michelangelo Rodriguez <michelangelo.rodriguez@gmail.com> writes:
> Hi Stefan, The file is greader.el, fetched from gitlab. The warning
> is at line 203, at least the line reported by the compiler. Thanks in
> advance.
Yes, it's as Stefan told you some minutes ago.
I also see these warnings:
| greader.el:182:10:Warning: reference to free variable `greader'
Seems there's a quote missing.
| greader.el:235:12:Warning: reference to free variable `dtk-quiet'
That variable should probably be declared.
...etc. But I guess you can cope with the other warnings?
Michael.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-02-05 21:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).