From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: [External] : Re: Lexical vs. dynamic: small examples? Date: Thu, 26 Aug 2021 02:10:59 +0200 Message-ID: <87o89ljca4.fsf@zoho.eu> References: <4a9bddb9ec57299b3b0c@heytings.org> <87y293sdxk.fsf@zoho.eu> <87pmufs4er.fsf@zoho.eu> <87wnompmpw.fsf@zoho.eu> <87k0kmgycz.fsf@gnus.org> <87y292nya4.fsf@zoho.eu> <87o89r5uwc.fsf@zoho.eu> <871r6hksj1.fsf@zoho.eu> <87wno9jdp7.fsf@zoho.eu> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40412"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:pWWnKYsDVQ+aYZkzcS2dLecjbJo= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 26 02:39:10 2021 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 1mJ3QE-000AM2-J7 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 26 Aug 2021 02:39:10 +0200 Original-Received: from localhost ([::1]:60542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJ3QC-0004Kd-Tr for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 25 Aug 2021 20:39:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJ2zJ-0004I6-EC for help-gnu-emacs@gnu.org; Wed, 25 Aug 2021 20:11:26 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:42160) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJ2zB-0001Uc-Ji for help-gnu-emacs@gnu.org; Wed, 25 Aug 2021 20:11:19 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mJ2z8-0008iV-Li for help-gnu-emacs@gnu.org; Thu, 26 Aug 2021 02:11:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.help:132722 Archived-At: > Now the byte-compiler instead warns about a reference to > a free variable. Maybe it shouldn't do that and instead warn > when one uses `defvar'? The byte-compiler also warns about the assignment to the same variable, this is the `setq' line. geh.el: In toplevel form: geh.el:15:7: Warning: assignment to free variable ‘b’ In fun: geh.el:18:3: Warning: reference to free variable ‘b’ Other byte-compiler questions are, why does it stop warning after a second compilation? Because there is no change to the source file, so no compilation happens? But doesn't that mean you can just compile away the shortcomings of the code? Also, why does the warnings appear so many times? The file (geh.el) isn't `require'd or anything from any other file. Just `load'ed, once. Yet both warnings appear 6 times! And all the cl warnings, from slime ... slime stuff is required from two files, `slime' but also `slime-presentations', `slime-autoloads', `slime-banner', and `slime-reply'. (I use a/the MELPA version, 2.26.1.) Anyway, that warning appear 12 times! See output after geh.el, and last the Makefile. ;;; -*- lexical-binding: t -*- ;;; ;;; this file: ;;; http://user.it.uu.se/~embe8573/emacs-init/geh.el ;;; https://dataswamp.org/~incal/emacs-init/geh.el (defmacro slet (bindings &rest body) (unless lexical-binding (error "`slet' requires `lexical-binding' to be enabled") ) `(funcall (lambda ,(mapcar #'car bindings) ,@body) ,@(mapcar #'cadr bindings) )) (setq b 200) (defun fun () b) ; geh.el:18:3: Warning: reference to free variable ‘b’ (slet ((b 1)) (list b (fun)) ) ; (1 200) (let ((b 2)) (list b (fun))) ; (2 200) (how-many "Warning: assignment to free variable ‘b’" (point) (point-max)) ; 6 (how-many "Warning: reference to free variable ‘b’" (point) (point-max)) ; 6 (how-many "Warning: Package cl is deprecated" (point) (point-max)) ; 12 erc/erc-kill.el: erc/erc-iterate.el: In toplevel form: geh.el:15:7: Warning: assignment to free variable ‘b’ In fun: geh.el:18:3: Warning: reference to free variable ‘b’ In toplevel form: geh.el:15:7: Warning: assignment to free variable ‘b’ In fun: geh.el:18:3: Warning: reference to free variable ‘b’ frame-size.el: erc/erc-spell.el: In toplevel form: geh.el:15:7: Warning: assignment to free variable ‘b’ In fun: geh.el:18:3: Warning: reference to free variable ‘b’ geh.el: get-search-string.el: In toplevel form: geh.el:15:7: Warning: assignment to free variable ‘b’ In fun: geh.el:18:3: Warning: reference to free variable ‘b’ In toplevel form: geh.el:15:7: Warning: assignment to free variable ‘b’ In fun: geh.el:18:3: Warning: reference to free variable ‘b’ In toplevel form: geh.el:15:7: Warning: assignment to free variable ‘b’ In fun: geh.el:18:3: Warning: reference to free variable ‘b’ gnus/mail.el: In toplevel form: ide/slime-incal.el:33:1: Warning: Package cl is deprecated ide/slime-incal.el: In toplevel form: ide/slime-incal.el:33:1: Warning: Package cl is deprecated global-keys.el: In toplevel form: ide/slime-incal.el:33:1: Warning: Package cl is deprecated face.el: ide/ide.el: In toplevel form: face.el:15:1: Warning: Package cl is deprecated In toplevel form: face.el:15:1: Warning: Package cl is deprecated sort-incal.el: street.el: In toplevel form: face.el:15:1: Warning: Package cl is deprecated In toplevel form: face.el:15:1: Warning: Package cl is deprecated string.el: In toplevel form: face.el:15:1: Warning: Package cl is deprecated navigate-fs-keys.el: In toplevel form: face.el:15:1: Warning: Package cl is deprecated super.el: scroll.el: In toplevel form: face.el:15:1: Warning: Package cl is deprecated In toplevel form: face.el:15:1: Warning: Package cl is deprecated string-minibuffer.el: In toplevel form: face.el:15:1: Warning: Package cl is deprecated # this file: # http://user.it.uu.se/~embe8573/emacs-init/Makefile # https://dataswamp.org/~incal/emacs-init/Makefile emacs=/usr/local/bin/emacs ema-path=~/.emacs.d/emacs-init ema-erc=\"${ema-path}/erc\" ema-gnus=\"${ema-path}/gnus\" ema-ide=\"${ema-path}/ide\" ema-init=\"${ema-path}\" ema-w3m=\"${ema-path}/w3m\" ema=${ema-erc} ${ema-gnus} ${ema-ide} ${ema-init} ${ema-w3m} elpa-path=~/.emacs.d/elpa markdown-mode=\"${elpa-path}/markdown-mode-20201220.253\" w3m=\"${elpa-path}/w3m-20210615.103\" elpa=${markdown-mode} ${w3m} slime=\"/usr/share/emacs/site-lisp/elpa-src/slime-2.26.1/\" packs=${ema} ${elpa} ${slime} byte-compile=$(emacs) \ --batch \ --eval "(setq load-path (append load-path '(${packs})))" \ -f batch-byte-compile sed-filter=2>&1 | sed '/^\(Loading\|Wrote\)/d' # errors and warnings only error-file=error.txt INIT_FILE=~/.emacs INIT_FILE_BC=$(INIT_FILE).elc ELS = $(shell zsh -c "ls -1 **/*.el") ELCS= $(ELS:.el=.elc) all: $(ELCS) $(INIT_FILE_BC) rm -f $(error-file) $(INIT_FILE_BC): $(INIT_FILE) $(byte-compile) $< $(sed-filter) %.elc: %.el $(byte-compile) $< $(sed-filter) > $(error-file) if [ -s $(error-file) ]; then echo -n "\n$<: "; cat $(error-file); fi rm -f $<~ clean: $(shell zsh -c "rm -rf **/*.elc(N)") rm -f $(INIT_FILE_BC) $(error-file) again: ${MAKE} clean ${MAKE} new: ${MAKE} again -- underground experts united https://dataswamp.org/~incal