unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Juan José García Ripoll" <juanjose.garcia.ripoll@csic.es>
To: 48219@debbugs.gnu.org
Subject: bug#48219: 27.1.90; CL-LOOP facility fails with hash tables
Date: Tue, 04 May 2021 10:46:57 +0200	[thread overview]
Message-ID: <86eeemnawu.fsf@csic.es> (raw)


(cl-loop
 for database in nil
 for aux = (message "databse: %S" database)
 for entry being the hash-values of database
 do (message "FOO %S" database))

This code should do nothing, because variable DATABASE runs over an empty list. Yet the macroexpansion of the loop produces code that tries to run over the entries of DATABASE, which is NIL.

(cl--block-wrapper
 (catch '--cl-block-nil--
   (let* ((--cl-var-- nil)
	  (database nil)
	  (aux nil))
     (cl-block --cl-finish--
       (maphash (lambda (--cl-var-- entry)
		  (or (consp --cl-var--) (cl-return-from --cl-finish-- nil))
		  (setq database (car --cl-var--))
		  (setq aux (message "databse: %S" database))
		  (message "FOO %S" database)
		  (setq --cl-var-- (cdr --cl-var--)))
		database))
     nil)))

Compare this with

(cl-prettyprint
 (macroexpand '(cl-loop
 for database in nil
 for aux = (message "databse: %S" database)
 do (message "FOO %S" database))))

(cl--block-wrapper
 (catch '--cl-block-nil--
   (let* ((--cl-var-- nil)
	  (database nil)
	  (aux nil))
     (while (consp --cl-var--)
       (setq database (car --cl-var--))
       (setq aux (message "databse: %S" database))
       (message "FOO %S" database)
       (setq --cl-var-- (cdr --cl-var--)))
     nil)))

Here the resulting code properly checks for the --cl-var-- variabel that runs the loop


In GNU Emacs 27.1.90 (build 1, x86_64-w64-mingw32)
Repository revision: 37eba74d609c74bcf9ac3c481a29377913783ac4
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.19042
System Description: Microsoft Windows 10 Pro (v10.0.2009.19042.928)

Recent messages:
nnimap read 0k from correo.csic.es [2 times]
No more unseen articles
No more unread articles
nnimap read 0k from correo.csic.es
No more unseen articles
No more unread articles
Auto-saving...done
Mark set
Replaced 122 occurrences
Calendar ~/Nextcloud/Documents/Notes/calendar.ics unchanged
Quit
Configured using:
 'configure
 --prefix=/c/Users/juanj/src/emacs-build/pkg/emacs-27_1_90-x86_64
 --with-zlib --with-gnutls --with-xml2 --with-lcms2 --with-json
 --with-harfbuzz --with-cairo --with-rsvg --with-png --with-gif
 --with-tiff --with-jpeg --with-xpm --disable-build-details
 --disable-silent-rules --without-dbus'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2
HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS JSON PDUMPER LCMS2 GMP

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

Major mode: Summary

Minor modes in effect:
  shell-dirtrack-mode: t
  display-time-mode: t
  which-key-mode: t
  icomplete-mode: t
  save-place-mode: t
  savehist-mode: t
  gcmh-mode: t
  override-global-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/modus-vivendi-theme-0.13.2/modus-vivendi-theme hides c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/modus-themes-1.2.4/modus-vivendi-theme
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/modus-operandi-theme-0.13.2/modus-operandi-theme hides c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/modus-themes-1.2.4/modus-operandi-theme
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-virtual hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-virtual
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-view hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-view
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-util hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-util
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-tools hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-tools
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-sync hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-sync
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-outline hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-outline
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-occur hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-occur
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-misc hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-misc
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-loader hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-loader
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-links hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-links
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-isearch hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-isearch
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-info hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-info
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-history hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-history
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-dev hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-dev
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-cache hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-cache
c:/Users/juanj/OneDrive/Library/Emacs/elpa-27/pdf-tools-0.90/pdf-annot hides c:/Users/juanj/scoop/apps/emacs/current/share/emacs/site-lisp/pdf-tools/pdf-annot

Features:
(shadow warnings emacsbug rng-xsd xsd-regexp rng-cmpct rng-nxml
rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util
rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap sgml-mode nxml-util
nxml-enc xmltok arc-mode archive-mode doc-view image-mode exif nnfolder
jka-compr misearch multi-isearch gnus-icalendar org-capture org-refile
org-tempo tempo org org-macro org-footnote org-pcomplete org-list
org-faces org-entities noutline outline org-version ob-python python
tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat shell pcomplete ob ob-tangle org-src ob-ref ob-lob ob-table
ob-exp ob-comint comint ring ob-emacs-lisp ob-core ob-eval org-table ol
org-keys org-compat org-macs org-loaddefs icalendar flow-fill smtpmail
flyspell ispell vc-git diff-mode mailalias sendmail bbdb-mua bbdb-com
crm bbdb bbdb-site timezone face-remap nnir mule-util sort smiley
ansi-color gnus-cite mm-archive mail-extr gnus-bcklg gnus-async qp
gnus-ml gnus-topic gnus-demon utf-7 nndraft nnmh nnmaild epa-file gnutls
network-stream nsm nnml nnnil gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig
nntp gnus-cache gnus-sum url url-proxy url-privacy url-expand
url-methods url-history shr url-cookie url-domsuf url-util svg xml dom
gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source
utf7 netrc nnoo parse-time iso8601 gnus-spec gnus-int gnus-range message
rmc puny dired dired-loaddefs format-spec rfc822 mml mml-sec epa derived
epg mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail
rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search
mail-utils mm-util mail-prsvr wid-edit time-date time cal-china lunar
solar cal-dst cal-bahai cal-islam cal-hebrew holidays hol-loaddefs appt
diary-lib diary-loaddefs cal-menu calendar cal-loaddefs
benchmark-init-modes debug backtrace find-func mailcap which-key
icomplete epg-config modus-operandi-theme modus-themes saveplace
savehist edmacro kmacro benchmark-init advice gcmh diminish cl-extra
help-mode use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key easy-mmode
use-package-core finder-inf tex-site info package easymenu browse-url
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp
disp-table term/w32-win w32-win w32-vars term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame minibuffer 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 composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
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 threads w32notify w32
lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 1068058 390211)
 (symbols 48 37670 37)
 (strings 32 286486 56033)
 (string-bytes 1 8189807)
 (vectors 16 85853)
 (vector-slots 8 2485239 445144)
 (floats 8 1011 1568)
 (intervals 56 14806 18837)
 (buffers 1000 184))

-- 
Juan José García Ripoll

Quantum Information and Foundations Group
Institute of Fundamental Physics IFF-CSIC
Calle Serrano 113b, Madrid 28006 Spain
http://quinfog.hbar.es - http://juanjose.garciaripoll.com





             reply	other threads:[~2021-05-04  8:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-04  8:46 Juan José García Ripoll [this message]
2022-07-01 12:03 ` bug#48219: 27.1.90; CL-LOOP facility fails with hash tables Lars Ingebrigtsen
2022-07-01 14:03   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-02 11:24     ` Lars Ingebrigtsen
2022-07-02 20:20       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-03 12:18         ` Lars Ingebrigtsen

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=86eeemnawu.fsf@csic.es \
    --to=juanjose.garcia.ripoll@csic.es \
    --cc=48219@debbugs.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.
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).