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

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

Re: How to tame compiler?


From: Jean Louis
Subject: Re: How to tame compiler?
Date: Sat, 1 May 2021 09:03:56 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Michael Heerdegen <michael_heerdegen@web.de> [2021-05-01 03:44]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > As I have recently implemented new function that use `eval' to expand
> > various variables and these variables are not visibly used in the
> > program, I would like to tame the compiler, as I get these warnings:
> >
> > In rcd-send-email:
> > rcd-mailing.el:225:62: Warning: Unused lexical variable `unsubscribe-url'
> > rcd-mailing.el:231:21: Warning: Unused lexical variable `hello-name'
> > rcd-mailing.el:234:72: Warning: Unused lexical variable `unsubscribe-text'
> > rcd-mailing.el:252:11: Warning: Unused lexical variable `body'
> >
> > What is happening here is that those variables are used but inside of
> > `eval' form which is expanded dynamically when program runs. Compiler
> > cannot see that.
> >
> > Is there a way to avoid these warnings?
> 
> Independent from the question whether your usage of `eval' is good or
> valid - there must be some real problem here: if the compiler tells that
> the lexical variables are unused, their values will not be available in
> you `eval' call - you would have to create dynamical bindings for
> that.

How do I go to create dynamical bindings? Help me.



This file works:

(let* ((hello-name "Joe")
       (template "⟦ hello-name ⟧")
       (expanded (rcd-template-eval template)))
  expanded) ⇒ "Joe"

while this one does not work:

;; -*- lexical-binding: t; -*-

(let* ((hello-name "Joe")
       (template "⟦ hello-name ⟧")
       (expanded (rcd-template-eval template)))
  expanded) ⇒ ""

and to make it work I did this:

;; -*- lexical-binding: t; -*-

(let* ((hello-name "Joe")
       (template "⟦ hello-name ⟧")
       (lexical-binding nil)
       (expanded (rcd-template-eval template)))
  expanded)

(ignore 'hello-name)

however, that simple example does not work, but what is astonishing I
have sent 900+ emails yesterday and they were expanded just fine.

The file test.el with above code is not working.

My file with lexical-binding: t is working.

I am using it and I do not know why it does work.

Without (lexical-binding nil) it did not work. It seems I have to use
that to make it work, but in smallest example it does not.

Maybe it is something completely else.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/




reply via email to

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