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 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/