GNU bug report logs -
#22961
The read function does not support a lambda argument
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22961 in the body.
You can then email your comments to 22961 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#22961
; Package
emacs
.
(Wed, 09 Mar 2016 16:28:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Mihai Călin Bazon <mihai.bazon <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 09 Mar 2016 16:28:01 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)]
Example, I eval this in the scratch buffer (with lexical-binding set true):
(read (let ((str "TEST")
(pos 0)
(prev nil))
(lambda (ch)
(cond
(ch (push ch prev))
(prev (pop prev))
((< pos (length str))
(prog1 (aref str pos)
(setq pos (1+ pos))))))))
According to the docs [1] an input stream can be a function. I would
expect the above to return the symbol TEST, but instead I get an error
("end of file during parsing").
[1]
http://www.gnu.org/software/emacs/manual/html_node/elisp/Input-Streams.html#Input-Streams
--
Mihai Bazon,
http://lisperator.net/
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22961
; Package
emacs
.
(Wed, 09 Mar 2016 18:28:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 22961 <at> debbugs.gnu.org (full text, mbox):
Mihai Călin Bazon <mihai.bazon <at> gmail.com> wrote:
> Example, I eval this in the scratch buffer (with lexical-binding set true):
>
> (read (let ((str "TEST")
> (pos 0)
> (prev nil))
> (lambda (ch)
> (cond
> (ch (push ch prev))
> (prev (pop prev))
> ((< pos (length str))
> (prog1 (aref str pos)
> (setq pos (1+ pos))))))))
>
> According to the docs [1] an input stream can be a function. I would expect
> the above to return the symbol TEST, but instead I get an error ("end of
> file during parsing").
Confirmed on Emacs 25. However, it does work with a named defun:
(let ((str "TEST")
(pos 0)
(prev nil))
(defun my-read-function (&optional ch)
(cond (ch (push ch prev))
(prev (pop prev))
((< pos (length str))
(prog1 (elt str pos)
(setq pos (1+ pos)))))))
(read #'my-read-function) ;=> TEST
(Mihai, the ‘ch’ argument should be ‘&optional’, though that's not
related to the error in question).
--
john
Reply sent
to
Andreas Schwab <schwab <at> linux-m68k.org>
:
You have taken responsibility.
(Wed, 09 Mar 2016 18:47:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Mihai Călin Bazon <mihai.bazon <at> gmail.com>
:
bug acknowledged by developer.
(Wed, 09 Mar 2016 18:47:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 22961-done <at> debbugs.gnu.org (full text, mbox):
Should be fixed in commit 711ca36.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22961
; Package
emacs
.
(Wed, 09 Mar 2016 20:32:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 22961 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I just re-built using this commit (
http://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-25&id=711ca362e7f8ca7c4f664dc2fe60bc5fa4e4f4fe
).
Now the earlier error went away, but I get
Symbol’s value as variable is void: prev
I guess the read call should be inside the let:
(let ((str "TEST")
(pos 0)
(prev nil))
(read (lambda (&optional ch)
(cond
(ch (push ch prev))
(prev (pop prev))
((< pos (length str))
(prog1 (aref str pos)
(setq pos (1+ pos))))))))
Above returns "TEST".
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22961
; Package
emacs
.
(Wed, 09 Mar 2016 21:11:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 22961 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
You should (setq lexical-binding t) before running it (and note that's
buffer-local, I've been bitten by that several times). With lexical
binding my original example should work (with the fix, as John pointed out,
that the argument should be &optional).
Thanks Andreas for the quick fix! :-)
On Wed, Mar 9, 2016 at 10:31 PM, Kaushal Modi <kaushal.modi <at> gmail.com>
wrote:
> I just re-built using this commit (
> http://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-25&id=711ca362e7f8ca7c4f664dc2fe60bc5fa4e4f4fe
> ).
>
> Now the earlier error went away, but I get
>
> Symbol’s value as variable is void: prev
>
> I guess the read call should be inside the let:
>
> (let ((str "TEST")
> (pos 0)
> (prev nil))
> (read (lambda (&optional ch)
> (cond
> (ch (push ch prev))
> (prev (pop prev))
> ((< pos (length str))
> (prog1 (aref str pos)
> (setq pos (1+ pos))))))))
>
> Above returns "TEST".
>
--
Mihai Bazon,
http://lisperator.net/
[Message part 2 (text/html, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 07 Apr 2016 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 78 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.