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: Stefan Monnier
Subject: Re: How to tame compiler?
Date: Fri, 30 Apr 2021 23:49:40 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Michael Heerdegen [2021-05-01 02:44:16] wrote:
> 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.

I know I sound like a broken clock, but I think a better answer is to
avoid `eval`: instead of taking expressions (that you'd pass to `eval`)
arrange to receive functions (which you'd pass to `funcall` or `apply`).
Then you can pass those functions the data they need (e.g. the value of
things like `unsubscribe-text`).


        Stefan




reply via email to

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