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

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

Re: On byte compilation


From: tpeplt
Subject: Re: On byte compilation
Date: Mon, 18 Sep 2023 15:07:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Petteri Hintsanen <petterih@iki.fi> writes:

> Hello,
>
> I'm converting some old code to use new bindat-type introduced in
> Emacs 28.1.  I'd like to keep the legacy forms for backwards
> compatibility with older emacsen.  But there is a problem with byte
> compilation.
>
> Toy example:
>
>   (defconst foo-bindat-spec
>     (eval-when-compile
>       (if (fboundp 'bindat-type)
>           (bindat-type  ;; new form
>             (id uint 32))
>         '((id u32))))  ;; legacy form
>     "Bindat spec for foo.")
>
> What I try to accomplish here is to assign to foo-bindat-spec either the
> result of (bindat-type ...) or list '((id u32)), depending on whether
> bindat-type macro is available or not.  However, Emacs' 27.2 byte
> compiler complains:
>
>   foo.el:5:14:Warning: reference to free variable ‘uint’
>

Emacs 28.2 reports this, also.  Did you mean 28.2 instead of 27.2?

‘uint’ is a symbol rather than a variable, according to the
documentation in the elisp info manual: (elisp)"Bindat Types".  So, it
is good that the compiler is warning you.  You would get the same
warning if you used:
  (id uintr 32) or (id str 32) or (id strz 32) or (id vec 32),...

The identifier ‘uint’ needs to be quoted: (id 'uint 32) or
alternatively, (id (quote uint) 32), if that is clearer to you.

(type-of uint) => error, void variable
(type-of 'uint) => symbol

Also, if you have not read it or haven’t read it recently, here is the
node in the elisp manual for Eval During Compile:
   (elisp) Eval During Compile

--



reply via email to

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