unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21185: 25.0.50; byte-compiler warn on quote lexical var
@ 2015-08-04  9:17 stephen_leake
  2015-08-06  3:28 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: stephen_leake @ 2015-08-04  9:17 UTC (permalink / raw)
  To: 21185

This file gives an example where a new byte-compiler warning would be
useful:

;; quote-lexical-var.el -*- lexical-binding: t -*-

(defun display-var (var)
  "Display variable value of VAR (a symbol), if any."
  (cond
   ((boundp var)
    (message "%s: %s" (symbol-name var) (symbol-value var)))

   (t
    (message "%s not bound" (symbol-name var)))))

(defun quote-lexical-var ()
  (let ((my-var "foo"))
    (message "non-quoted my-var: %s" my-var)
    (display-var 'my-var)))

(provide 'quote-lexical-var)
;; end of file

To see the problem, execute (in emacs master, -Q):

    (add-to-list 'load-path "/home/stephe/Elisp_Work/")
    ;; path containing above file

    (byte-compile-file  "/home/stephe/Elisp_Work/quote-lexical-var.el")
    (require 'quote-lexical-var)

    (display-var 'default-directory)

This gives "default-directory: /home/stephe" as expected.

    (quote-lexical-var)

This gives:

non-quoted my-var: foo
my-var: not bound

Quoting lexical variables does not work; there is no symbol available at
run-time.

I've been bitten by this problem when converting code to use lexical
binding; it would be helpful if the byte-compiler warned about it.


In GNU Emacs 25.0.50.4 (x86_64-w64-mingw32)
 of 2015-08-02 on TAKVER2
Repository revision: d2c4309d46529bac656f332677d2c5e199577845
Windowing system distributor `Microsoft Corp.', version 6.3.9600
Configured using:
 `configure --prefix=/mingw64
 PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib mail-prsvr
mail-utils time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table
w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote w32notify w32 multi-tty
make-network-process emacs)

Memory information:
((conses 16 82209 4908)
 (symbols 56 18803 0)
 (miscs 48 36 106)
 (strings 32 14166 4682)
 (string-bytes 1 381142)
 (vectors 16 10489)
 (vector-slots 8 395072 6302)
 (floats 8 121 16)
 (intervals 56 221 2)
 (buffers 976 11))





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-08 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-04  9:17 bug#21185: 25.0.50; byte-compiler warn on quote lexical var stephen_leake
2015-08-06  3:28 ` Stefan Monnier
2015-08-06  7:15   ` Stephen Leake
2021-07-08 14:12   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).