From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id eOCOJ4X8AF84WAAA0tVLHw (envelope-from ) for ; Sat, 04 Jul 2020 22:02:45 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id qCUyI4X8AF/QFwAAbx9fmQ (envelope-from ) for ; Sat, 04 Jul 2020 22:02:45 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DC38B9408FC for ; Sat, 4 Jul 2020 22:02:44 +0000 (UTC) Received: from localhost ([::1]:44006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrqF9-0003GM-Eb for larch@yhetil.org; Sat, 04 Jul 2020 18:02:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrqEn-0003Ft-IM for emacs-orgmode@gnu.org; Sat, 04 Jul 2020 18:02:21 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]:33261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jrqEm-0001jn-2N for emacs-orgmode@gnu.org; Sat, 04 Jul 2020 18:02:21 -0400 Received: by mail-ot1-x330.google.com with SMTP id h13so8440037otr.0 for ; Sat, 04 Jul 2020 15:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:from:date:message-id:subject:to; bh=8GOYuX23l9vYrrm6IJtk25i6MylgG93UIpJ3kF15fsQ=; b=kau2huM6IbfjRNAw4sbapdwEw6pORkMOQ/LfGC8XZlu67F9NS8IHxmRxTPxWT61PIK ZBSdl5MwWMomG6XCrfuGzZ2j6AGuvmj/XR63shL7yxGjSIGNyTGCTU1NWl/le2KyItze yK0d2cwliwsf/gpIE+KI/rKgO/koKcJ04SGyfjO7mUYheHj/781Lq12N394SPPErgtRr H6/c9ws6hpU3Y2AzUppKmlPpp2twyhgPpo3MbhNgajJjTPxJg96qpeZrgJriqsv13f6h lpu5JpBEL7lGo4+q9MD/STGGW7tMV4jdcF20YVTX/m6QYVOM3olNIf5SpYAIPwdCcJtV hqmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:from:date:message-id :subject:to; bh=8GOYuX23l9vYrrm6IJtk25i6MylgG93UIpJ3kF15fsQ=; b=UQtz68Tb0kvHovdUBhcnYHldOEISg7MHXzAXzUxtNBTsu0v37XZ5jyM7TyvlJn+vDp g/2Rv8xQ3BiVnLghG3MLDP7771wrrjSzs+s6jQYyJ7HWti8o9ZcWd9nVmPes+4bG7Y/L 9cLVEIsh1hEmfaL4f25CfPM1W7hilqhe6ODjrDJvbyqylmk7UTK2mWE2Iuu0/IskwKbF 0FhNHags4Lw7YaBxq6V1aLUeJeSY7InLpomEicIMtQ7FW0bf0dL52ISO2Xb3pYYaVGkw f4lHlc44W034bJUsRAzYYmy4OZQ35Swy3xmtR2CVkjckDwhXgVZwceUjURQNNcK4Y2EJ fUkw== X-Gm-Message-State: AOAM533NJ82HV1x4avx+34y63Fdge4BQJ02euO9FgncERQSA4lNLyMlY ZXSj3ZeUB3b97Jvid5yrt/NZMPMealH4oU9osylvJxcVz7s= X-Google-Smtp-Source: ABdhPJw7iM3w/C7cF3vTbAz+pO5ID5dulPXnEsNwgPwqMIlYnBhSj3c1ZpbLvGFBTG4tQr+g5b7wdn6ir0/a4rWK8Bc= X-Received: by 2002:a9d:904:: with SMTP id 4mr37544194otp.339.1593900137919; Sat, 04 Jul 2020 15:02:17 -0700 (PDT) MIME-Version: 1.0 From: George Mauer Date: Sat, 4 Jul 2020 17:02:07 -0500 Message-ID: Subject: Get generators working in an src block? To: emacs-orgmode Content-Type: multipart/alternative; boundary="000000000000873d7405a9a4cbe3" Received-SPF: pass client-ip=2607:f8b0:4864:20::330; envelope-from=gmauer@gmail.com; helo=mail-ot1-x330.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: gmauer@gmail.com Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=kau2huM6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: JVgWz1RABd8B --000000000000873d7405a9a4cbe3 Content-Type: text/plain; charset="UTF-8" I prefer to use source blocks for pretty much all my language learning. I am trying to figure out generators in emacs-lisp but can't seem to run it in a block. I have ``` #+begin_src emacs-lisp :results output (setq lexical-binding t) (require 'generator) (iter-defun my-iter (x) (let (val (iter-yield (1+ x))) (iter-yield (1+ val))) -1) (let* ((it1 (my-iter 5)) (it2 (my-itr 0))) (print (iter-next it1)) (print (iter-next it1 8)) (print (iter-next it2 nil)) (condition-case x (iter-next it1) (iter-end-of-sequence (print (cdr x))))) #+end_src ``` But running that gives me > executing Emacs-Lisp code block... > cl--assertion-failed: Assertion failed: lexical-binding I thought that setting lexical-binding to t was enough, but apparently something else is needed? --000000000000873d7405a9a4cbe3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I prefer to use source b= locks for pretty much all my language learning.

I am try= ing to figure out generators in emacs-lisp but can't seem to run it in = a block.

I have

```
=
=C2=A0 =C2=A0 #+begin_src emacs-lisp :results output
= =C2=A0 =C2=A0 =C2=A0 (setq lexical-binding t)
=C2=A0 =C2=A0 =C2= =A0 (require 'generator)

=C2=A0 =C2=A0 =C2=A0 = (iter-defun my-iter (x)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (let (val (it= er-yield (1+ x)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (iter-yield = (1+ val)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 -1)

=C2=A0 =C2=A0 =C2=A0 (let* ((it1 (my-iter 5))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(it2 (my-itr 0)))
=C2=A0 =C2=A0= =C2=A0 =C2=A0 (print (iter-next it1))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 (print (iter-next it1 8))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (print = (iter-next it2 nil))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (condition-case = x
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (iter-next it1)
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (iter-end-of-sequence
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(print (cdr x)))))
=C2=A0 = =C2=A0 #+end_src
```

But running t= hat gives me

> executing Emacs-Lisp code block.= ..
> cl--assertion-failed: Assertion failed: lexical-binding

I thought that setting lexical-binding to t was eno= ugh, but apparently something else is needed?
--000000000000873d7405a9a4cbe3--