GNU bug report logs -
#22812
24.5: elisp manual about pcase
Previous Next
Reported by: Zhaohui Li <lizhaohui1991 <at> gmail.com>
Date: Fri, 26 Feb 2016 02:35:02 UTC
Severity: minor
Found in version 24.5
Done: Michael Heerdegen <michael_heerdegen <at> web.de>
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 22812 in the body.
You can then email your comments to 22812 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22812
; Package
emacs
.
(Fri, 26 Feb 2016 02:35:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Zhaohui Li <lizhaohui1991 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 26 Feb 2016 02:35:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The "10.2.1: Pattern matching case statement" in Emacs Lisp Referrence
Manual has a problem.
The second example in manual is:
> (defun evaluate (exp env)
> (pcase exp
> (`(add ,x ,y) (+ (evaluate x env) (evaluate y env)))
> (`(call ,fun ,arg) (funcall (evaluate fun env) (evaluate arg
> env)))
> (`(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))))
>
The problem is about the third case: `(fn , arg ,body).
I test this function with:
> (evaluate '(call
> (fn x (add 1 x))
> 2)
> nil)
>
emcas eval it with throw errors.
I think the correct of this function should be:
> (defun evaluate (exp env)
> (pcase exp
> (`(add ,x ,y)
> (+ (evaluate x env)
> (evaluate y env)))
> (`(call ,fun ,arg)
> (funcall (evaluate fun env)
> (evaluate arg env)))
> (`(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))))
>
Thanks~
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22812
; Package
emacs
.
(Fri, 26 Feb 2016 13:02:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 22812 <at> debbugs.gnu.org (full text, mbox):
Zhaohui Li <lizhaohui1991 <at> gmail.com> writes:
> The "10.2.1: Pattern matching case statement" in Emacs Lisp Referrence
> Manual has a problem. The second example in manual is:
>
>
> (defun evaluate (exp env)
> (pcase exp
> (`(add ,x ,y) (+ (evaluate x env) (evaluate y env)))
> (`(call ,fun ,arg) (funcall (evaluate fun env) (evaluate arg env)))
> (`(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))))
>
>
> The problem is about the third case: `(fn , arg ,body).
> I test this function with:
>
>
> (evaluate '(call
> (fn x (add 1 x))
> 2)
> nil)
>
>
> emcas eval it with throw errors.
Works for me. Did you enable lexical binding when testing?
Regards,
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22812
; Package
emacs
.
(Fri, 26 Feb 2016 15:44:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 22812 <at> debbugs.gnu.org (full text, mbox):
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Date: Fri, 26 Feb 2016 14:01:10 +0100
> Cc: 22812 <at> debbugs.gnu.org
>
> > (evaluate '(call
> > (fn x (add 1 x))
> > 2)
> > nil)
> >
> >
> > emcas eval it with throw errors.
>
> Works for me. Did you enable lexical binding when testing?
Should we add a comment to the manual with this caveat?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22812
; Package
emacs
.
(Fri, 26 Feb 2016 16:31:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 22812 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> > Works for me. Did you enable lexical binding when testing?
>
> Should we add a comment to the manual with this caveat?
There is one, quite before the example:
> Here is an example of using ‘pcase’ to implement a simple interpreter
> for a little expression language (note that this example requires
> lexical binding, *note Lexical Binding::): [...]
Michael.
Reply sent
to
Michael Heerdegen <michael_heerdegen <at> web.de>
:
You have taken responsibility.
(Sat, 27 Feb 2016 19:41:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Zhaohui Li <lizhaohui1991 <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 27 Feb 2016 19:41:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 22812-done <at> debbugs.gnu.org (full text, mbox):
Ok, the example runs fine with lexical-binding enabled; thanks
nevertheless. Closing.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 27 Mar 2016 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 87 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.