unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: tpeplt <tpeplt@gmail.com>
To: Petteri Hintsanen <petterih@iki.fi>
Cc: help-gnu-emacs@gnu.org
Subject: Re: On byte compilation
Date: Mon, 18 Sep 2023 15:07:36 -0400	[thread overview]
Message-ID: <87bkdz2tc7.fsf@gmail.com> (raw)
In-Reply-To: <x2mwmwo3b27.fsf@iki.fi> (Petteri Hintsanen's message of "Sun, 17 Sep 2023 21:32:32 +0300")

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	other threads:[~2023-09-18 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-17 18:32 On byte compilation Petteri Hintsanen
2023-09-18 19:07 ` tpeplt [this message]
2023-09-19 22:47   ` tpeplt

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkdz2tc7.fsf@gmail.com \
    --to=tpeplt@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=petterih@iki.fi \
    /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.
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).