From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tpeplt Newsgroups: gmane.emacs.help Subject: Re: On byte compilation Date: Tue, 19 Sep 2023 18:47:34 -0400 Message-ID: <87cyydu6ex.fsf@gmail.com> References: <87bkdz2tc7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39829"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Petteri Hintsanen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 20 00:48:30 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qijW9-000A9j-Br for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 20 Sep 2023 00:48:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qijVN-0002uW-46; Tue, 19 Sep 2023 18:47:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qijVL-0002u8-7K for help-gnu-emacs@gnu.org; Tue, 19 Sep 2023 18:47:39 -0400 Original-Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qijVJ-0000Tv-MM for help-gnu-emacs@gnu.org; Tue, 19 Sep 2023 18:47:39 -0400 Original-Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-6564fe1967dso1649056d6.1 for ; Tue, 19 Sep 2023 15:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695163656; x=1695768456; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=eux7xTaoSe9bBSd7aej1lq+8pHao3ZWgbeQZHa04B1Y=; b=HPTv0trCjc0WG8+vPFm1Hm5n1k5KAyt5Pvhewo28Wd+NW+PCAj0Jw4V0+3D5y8j+Dp B0z1MWUZ4H660dLmmRlGa4cVP6U6Aa9fpDAKjJzWjNFTiooGMbTdEx1D5rXS+lB6ucdh 1U2cS+tDG2gDJsHqCvnsHQwJInI5XnT+kls4UI13DZKtMuZrs41tHxN9Q+L1pfzdmyt0 xBzvHwWw6NrBxvypbP+WNduE+IYhsqr63ojlegItGhCFsQ/KIYg75+ZvweEEjmInVhZi 1EzIsJY0TgkxMC3QsJo+E9PSXfjT+bGgWQh50TRGa14Pd/K+PMBdkjXQjGwH8w5YjEDT blNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695163656; x=1695768456; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eux7xTaoSe9bBSd7aej1lq+8pHao3ZWgbeQZHa04B1Y=; b=pTNMNpbA3ZMyHqiJFDiPekdgkEJL1snfsMnEgeSA/jAqEKOnp7zURnrXLFs6K/LGPa KtD5TaIbN070GaX3KhOrKYH7REB3a2Myvo6xF5YqSbU8WwDZiPj/t4cKEPNiAdVsrkEY kfnZHCTqGBBwDd0dppIsA/TuJ8KOQdQguFU06yIT72SIrKP4gS0eEjLCzHDFPM/eGTE3 0Ar+nnVw4SjvhJNu3uxseBIpXYyzob0zpdHeIRwxkTQKT5bYOwouI07kHzUi3sCi4U1C xSBphd8mcuCz4EkKPLDR3AGjO+c16oCZSMAcuCZEu+5MQdO1YP5DTjgJY9l2VxBrmk6S B8tg== X-Gm-Message-State: AOJu0YxtguWiagXYy9vlaKuHXw4ILYRhIzNBdoAQVPWcCCgOZUzBFey3 5lYdxj9aXS6dagDzmNE9swI= X-Google-Smtp-Source: AGHT+IEBMuVF1XGiy73Ry+KiGtLZ6f2diHBImYlhluzqa44Grrt5JCV/I4/bMHPdPdpF0pf6Jcc4aA== X-Received: by 2002:a05:6214:400d:b0:658:2fd6:ef73 with SMTP id kd13-20020a056214400d00b006582fd6ef73mr4191961qvb.14.1695163656282; Tue, 19 Sep 2023 15:47:36 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a821:2b00::354f]) by smtp.gmail.com with ESMTPSA id u20-20020a0cdd14000000b006581e82a628sm2160182qvk.134.2023.09.19.15.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 15:47:35 -0700 (PDT) In-Reply-To: <87bkdz2tc7.fsf@gmail.com> (tpeplt@gmail.com's message of "Mon, 18 Sep 2023 15:07:36 -0400") Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=tpeplt@gmail.com; helo=mail-qv1-xf32.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145144 Archived-At: tpeplt writes: > Petteri Hintsanen writes: > >> Hello, >> >> I'm converting some old code to use new bindat-type introduced in >> Emacs=C2=A028.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 =E2=80=98uint=E2=80=99 >> > > Emacs 28.2 reports this, also. Did you mean 28.2 instead of 27.2? > > =E2=80=98uint=E2=80=99 is a symbol rather than a variable, according to t= he > 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 =E2=80=98uint=E2=80=99 needs to be quoted: (id 'uint 32) or > alternatively, (id (quote uint) 32), if that is clearer to you. > > (type-of uint) =3D> error, void variable > (type-of 'uint) =3D> symbol > > Also, if you have not read it or haven=E2=80=99t read it recently, here i= s the > node in the elisp manual for Eval During Compile: > (elisp) Eval During Compile > > -- I was mistaken. According to the parent node of (elisp)Bindat Types, that is, node (elisp) Byte Packing: "To use the functions referred to in this section, load the =E2=80=98bin= dat=E2=80=99 library." So, if we take your example, and first evaluate the expression: (require 'bindat) Then your example evaluates and compiles (and lints) without any warnings or errors. --