1

I want to try new features in emacs 26, I'm using emacs 27, generators and threads, but when I try to use on ielm buffer, I get the same error:

ELISP> (iter-defun my-iter (x)
  (iter-yield (1+ (iter-yield (1+ x))))
   ;; Return normally
  -1)
*** Eval error ***  Assertion failed: lexical-binding

This example is from ergoemacs

4

TL;DR

M-: (setq lexical-binding t)

Details

A precondition for iterators in Emacs to work is that the variable binding is set to lexical binding for the respective file or buffer.

Evaluate

(setq lexical-binding t)

to turn on lexical binding.

The assertion can be interpreted to make sure that lexical binding is set when using iterators.

Find more about lexical binding in the elisp in the info pages. See section (info "(elisp) Variable Scoping").

| improve this answer | |
  • 1
    I'm running into this too, but rather than ielm, I prefer to use org mode src blocks wherever possible. Any clue what I need to do there? simply adding (setq lexical-binding t) to my block doesn't do the trick – George Mauer Jul 4 at 21:58
  • I guess Kyle answered that over at orgmode.org/list/87pn9akdvw.fsf@kyleam.com/T/…. For the record and convenience: use header argument :lexical yes. – Marco Wahl Jul 5 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.