unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Petteri Hintsanen <petterih@iki.fi>
To: help-gnu-emacs@gnu.org
Subject: On byte compilation
Date: Sun, 17 Sep 2023 21:32:32 +0300	[thread overview]
Message-ID: <x2mwmwo3b27.fsf@iki.fi> (raw)

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’

even though (fboundp 'bindat-type) evaluates to nil with that Emacs
version.  The resulting elc seems to be ok (?) despite the warning:

  #@22 Bindat spec for foo.
  (defconst foo-bindat-spec '((id u32)) (#$ . 408))

If I relocate eval-when-compile like this

  (defconst foo-bindat-spec
    (if (eval-when-compile (fboundp 'bindat-type))
        (bindat-type  ;; new form
          (id uint 32))
      '((id u32)))  ;; legacy form
    "Bindat spec for foo.")

then the byte compiler does not complain.  Could someone please explain
why?

Thanks,
Petteri




             reply	other threads:[~2023-09-17 18:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-17 18:32 Petteri Hintsanen [this message]
2023-09-18 19:07 ` On byte compilation tpeplt
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=x2mwmwo3b27.fsf@iki.fi \
    --to=petterih@iki.fi \
    --cc=help-gnu-emacs@gnu.org \
    /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).