GNU bug report logs - #49647
27.2; Reference Manual sec. 10.2.4; Incorrect example for indirect-function

Previous Next

Package: emacs;

Reported by: Scott Marks <scott.c.marks <at> gmail.com>

Date: Mon, 19 Jul 2021 18:58:01 UTC

Severity: normal

Found in version 27.2

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49647 in the body.
You can then email your comments to 49647 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#49647; Package emacs. (Mon, 19 Jul 2021 18:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Scott Marks <scott.c.marks <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 19 Jul 2021 18:58:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Scott Marks <scott.c.marks <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.2; Reference Manual sec. 10.2.4;
 Incorrect example for indirect-function
Date: Mon, 19 Jul 2021 14:38:34 -0400
[Message part 1 (text/plain, inline)]
If one copies the example:


Here is how you could define indirect-function in Lisp:


(defun indirect-function (function)

  (if (symbolp function)

      (indirect-function (symbol-function function))

    function))


this code will throw due to infinite recursion when invoked as


(indirect-function nil)


The fix is obvious: wrap (symbolp function) with (and function ...)


I don't think this would distract from the point of the example.


Hope this helps

Scott


In GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
Version 10.14.6 (Build 18G95))

 of 2021-03-27 built on builder10-14.porkrind.org

Windowing system distributor 'Apple', version 10.3.2022

System Description:  macOS 11.4


Recent messages:

Quit

Mark set

Quit

<nil> <down-mouse-1> is undefined

<nil> <mouse-1> is undefined

kill-region: Text is read-only: #<buffer *ielm*> [2 times]

<nil> <down-mouse-1> is undefined

<nil> <mouse-1> is undefined

Quit [4 times]

Configured using:

 'configure --with-ns '--enable-locallisppath=/Library/Application

 Support/Emacs/${version}/site-lisp:/Library/Application

 Support/Emacs/site-lisp' --with-modules'


Configured features:

NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

THREADS JSON PDUMPER GMP


Important settings:

  value of $LANG: en_US.UTF-8

  locale-coding-system: utf-8-unix


Major mode: IELM


Minor modes in effect:

  override-global-mode: t

  global-git-commit-mode: t

  magit-auto-revert-mode: t

  shell-dirtrack-mode: t

  gcmh-mode: t

  straight-use-package-mode: t

  straight-package-neutering-mode: t

  desktop-save-mode: t

  tooltip-mode: t

  global-eldoc-mode: t

  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


Load-path shadows:

/Users/scott/.emacs.d/straight/build/let-alist/let-alist hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/let-alist


Features:

(shadow sort mail-extr emacsbug sendmail misearch multi-isearch cl-print

ielm pp etags fileloop generator xref project dired-aux sh-script smie

executable jka-compr vc-git my-haskell-elisp-autoloads

use-package-bind-key bind-key hindent-autoloads hlint-refactor-autoloads

flycheck-haskell-autoloads dante-autoloads lcr-autoloads

company-autoloads haskell-mode-autoloads attrap flycheck find-func s

attrap-autoloads flycheck-autoloads let-alist-autoloads

pkg-info-autoloads epl-autoloads f-autoloads s-autoloads magit-gitflow

magit-popup magit-gitflow-autoloads magit-popup-autoloads

magit-submodule magit-obsolete magit-blame magit-stash magit-reflog

magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote

magit-commit magit-sequence magit-notes magit-worktree magit-tag

magit-merge magit-branch magit-reset magit-files magit-refs magit-status

magit package browse-url url-handlers magit-repos magit-apply magit-wip

magit-log which-func imenu magit-diff smerge-mode diff diff-mode

git-commit rx log-edit message rfc822 mml mml-sec epa derived epg

epg-config gnus-util rmail rmail-loaddefs text-property-search mm-decode

mm-bodies mm-encode mailabbrev gmm-utils mailheader pcvs-util add-log

magit-core magit-autorevert autorevert filenotify magit-margin

magit-transient magit-process with-editor server magit-mode transient

magit-git magit-section magit-utils crm dash magit-autoloads

magit-section-autoloads git-commit-autoloads with-editor-autoloads

transient-autoloads pandoc-mode-autoloads dash-autoloads hydra-autoloads

lv-autoloads markdown-mode-autoloads dirtrack native-complete

native-complete-autoloads dired dired-loaddefs edmacro kmacro

exec-path-from-shell exec-path-from-shell-autoloads ffap tramp

tramp-loaddefs trampver tramp-integration files-x tramp-compat shell

pcomplete comint ansi-color ring parse-time iso8601 time-date ls-lisp

format-spec finder-inf gcmh gcmh-autoloads cl-extra use-package-core

use-package-autoloads bind-key-autoloads straight-autoloads straight

info autoload radix-tree easy-mmode pcase checkdoc lisp-mnt thingatpt

help-mode easymenu mail-utils gnutls network-stream url-http mail-parse

rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm rmc

puny url-cache url-auth url url-proxy url-privacy url-expand url-methods

url-history url-cookie url-domsuf url-util url-parse auth-source cl-seq

eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map

seq byte-opt gv bytecomp byte-compile cconv url-vars mailcap

deeper-blue-theme desktop frameset cl-loaddefs cl-lib cus-start cus-load

tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type

mwheel term/ns-win ns-win ucs-normalize mule-util 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 kqueue cocoa ns multi-tty make-network-process emacs)


Memory information:

((conses 16 210890 189150)

 (symbols 48 21515 1)

 (strings 32 69271 38020)

 (string-bytes 1 2340771)

 (vectors 16 38156)

 (vector-slots 8 828157 241244)

 (floats 8 125 1238)

 (intervals 56 2074 118)

 (buffers 1000 30))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49647; Package emacs. (Tue, 20 Jul 2021 00:00:02 GMT) Full text and rfc822 format available.

Message #8 received at 49647 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Scott Marks <scott.c.marks <at> gmail.com>
Cc: 49647 <at> debbugs.gnu.org
Subject: Re: bug#49647: 27.2; Reference Manual sec. 10.2.4; Incorrect
 example for indirect-function
Date: Tue, 20 Jul 2021 01:59:06 +0200
Scott Marks <scott.c.marks <at> gmail.com> writes:

> If one copies the example:

You mean from the manual, (info "(elisp) Function Indirection") I think.

>  Here is how you could define indirect-function in Lisp:
>
>  (defun indirect-function (function)
>
>    (if (symbolp function)
>
>        (indirect-function (symbol-function function))
>
>      function))
>
> this code will throw due to infinite recursion when invoked as
>
> (indirect-function nil)
>
> The fix is obvious: wrap (symbolp function) with (and function ...)

In my opinion your analysis is correct and the fix is good.

I leave it to the second reader to make the change.


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49647; Package emacs. (Tue, 20 Jul 2021 12:08:02 GMT) Full text and rfc822 format available.

Message #11 received at 49647 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Scott Marks <scott.c.marks <at> gmail.com>, 49647 <at> debbugs.gnu.org
Subject: Re: bug#49647: 27.2; Reference Manual sec. 10.2.4; Incorrect
 example for indirect-function
Date: Tue, 20 Jul 2021 14:06:59 +0200
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> In my opinion your analysis is correct and the fix is good.
>
> I leave it to the second reader to make the change.

Now done.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 49647 <at> debbugs.gnu.org and Scott Marks <scott.c.marks <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 20 Jul 2021 12:08:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 18 Aug 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 252 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.