GNU bug report logs - #22961
The read function does not support a lambda argument

Previous Next

Package: emacs;

Reported by: Mihai Călin Bazon <mihai.bazon <at> gmail.com>

Date: Wed, 9 Mar 2016 16:28:01 UTC

Severity: normal

Done: Andreas Schwab <schwab <at> linux-m68k.org>

Bug is archived. No further changes may be made.

Full log


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

From: John Mastro <john.b.mastro <at> gmail.com>
To: 22961 <at> debbugs.gnu.org
Cc: Mihai Călin Bazon <mihai.bazon <at> gmail.com>
Subject: Re: bug#22961: The read function does not support a lambda argument
Date: Wed, 9 Mar 2016 10:27:28 -0800
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




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.