GNU bug report logs -
#16238
24.3.50; pcase docs (and possibly pcase) wrong
Previous Next
Reported by: Tassilo Horn <tsdh <at> gnu.org>
Date: Tue, 24 Dec 2013 09:15:02 UTC
Severity: minor
Found in version 24.3.50
Done: Tassilo Horn <tsdh <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#16238: 24.3.50; pcase docs (and possibly pcase) wrong
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 16238 <at> debbugs.gnu.org.
--
16238: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16238
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Closing.
[Message part 3 (message/rfc822, inline)]
I'm just reading through the `pcase' docs in the info manual. The
simple expression language example has a small bug. The `env' parameter
is missing at the location marked below:
--8<---------------cut here---------------start------------->8---
(defun evaluate (exp env)
(pcase exp
(`(add ,x ,y) (+ (evaluate x env) (evaluate y env)))
(`(call ,fun ,arg) (funcall (evaluate fun) (evaluate arg env)))
`--- HERE!
(`(fn ,arg ,body) (lambda (val)
(evaluate body (cons (cons arg val) env))))
((pred numberp) exp)
((pred symbolp) (cdr (assq exp env)))
(_ (error "Unknown expression %S" exp))))
--8<---------------cut here---------------end--------------->8---
But even then, I can't get `fn' forms working:
ELISP> (evaluate '(fn x (add 1 x)) nil)
(lambda
(val)
(evaluate body
(cons
(cons arg val)
env)))
But shouldn't `arg' be substituted with 'x and `body' with '(add 1 x)?
Now when I call the function, I get a void-variable error whereas I
should get 3:
ELISP> (evaluate '(call (fn x (add 1 x)) 2) nil)
*** Eval error *** Symbol's value as variable is void: body
Strange enough, the `call' pattern which uses the same pattern syntax
seems to work, though:
ELISP> (evaluate '(call foo 2) '((foo . (lambda (x) (+ 1 x)))))
3 (#o3, #x3, ?\C-c)
In any case, it would be good if the docs would contain a sample program
defined in the simple expression language. Getting the syntax right
just from the patterns is not enough. For example, it's not obvious
that `fn' forms take only one symbol as `arg' whereas you'd usually
expect an argument list (which might be restricted to length 1).
In GNU Emacs 24.3.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.8.7)
of 2013-12-22 on thinkpad
Bzr revision: eliz <at> gnu.org-20131222183138-zlzn9zzpz1hwd110
Windowing system distributor `The X.Org Foundation', version 11.0.11499904
System Description: NAME=Gentoo
Configured using:
`configure --prefix=/usr --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --mandir=/usr/share/man
--infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
--localstatedir=/var/lib --libdir=/usr/lib64 --disable-silent-rules
--disable-dependency-tracking --program-suffix=-emacs-24-vcs
--infodir=/usr/share/info/emacs-24-vcs
--enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
--with-gameuser=games --without-compress-info
--with-file-notification=gfile --disable-acl --with-dbus --with-gnutls
--with-gpm --without-hesiod --without-kerberos --without-kerberos5
--with-xml2 --without-selinux --without-wide-int --with-zlib
--with-sound=alsa --with-x --without-ns --without-gconf
--with-gsettings --with-toolkit-scroll-bars --with-gif --with-jpeg
--with-png --with-rsvg --with-tiff --with-xpm --with-imagemagick
--with-xft --with-libotf --with-m17n-flt --with-x-toolkit=gtk3
GENTOO_PACKAGE=app-editors/emacs-vcs-24.3.9999 EBZR_BRANCH=trunk
EBZR_REVNO=115696 'CFLAGS=-march=native -pipe -g3 -ggdb' CPPFLAGS=
'LDFLAGS=-Wl,-O1 -Wl,--as-needed''
Important settings:
value of $LC_COLLATE: C
value of $LC_MONETARY: de_DE.utf8
value of $LC_NUMERIC: de_DE.utf8
value of $LC_TIME: de_DE.utf8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
helm-match-plugin-mode: t
helm-occur-match-plugin-mode: t
highlight-parentheses-mode: t
global-company-mode: t
company-mode: t
eldoc-mode: t
shell-dirtrack-mode: t
paredit-mode: t
highlight-symbol-mode: t
global-edit-server-edit-mode: t
outline-minor-mode: t
recentf-mode: t
global-subword-mode: t
subword-mode: t
savehist-mode: t
show-paren-mode: t
icomplete-mode: t
minibuffer-depth-indicate-mode: t
tooltip-mode: t
electric-pair-mode: t
electric-indent-mode: t
mouse-wheel-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
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
This bug report was last modified 11 years and 155 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.