all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#28990: 27.0.50; thunk-delay: running expansion also requires lexical-binding
@ 2017-10-25 13:47 Michael Heerdegen
  2017-10-27 14:08 ` Michael Heerdegen
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2017-10-25 13:47 UTC (permalink / raw)
  To: 28990; +Cc: Nicolas Petton


Hello,

having only lexical-binding: t in "thunk.el"'s header is not sufficient:
to make thunks work ok, `thunk-delay' needs lexical-binding when the
expansion is run.

Try e.g. something trivial as

#+begin_src emacs-lisp
(defun my-thunk-test ()
  (thunk-force (thunk-delay (+ 1 2))))
#+end_src

This compiles ok, but executing (my-thunk-test) without lexbind enabled
gives you a meaningless error like "void-variable: forced".

I think we should document (in the file header) that lexical-binding
mode is required when thunks are created with `thunk-delay'.  I think we
could additionally raise an error in the expansion of `thunk-delay' when
lexical-binding -> nil.


TIA,

Michael.




In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.24)
 of 2017-10-25 built on drachen
Repository revision: cb73c70180f57f3fb99fae3aaefbacf0a61cea3f
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description:	Debian GNU/Linux testing (buster)






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#28990: 27.0.50; thunk-delay: running expansion also requires lexical-binding
  2017-10-25 13:47 bug#28990: 27.0.50; thunk-delay: running expansion also requires lexical-binding Michael Heerdegen
@ 2017-10-27 14:08 ` Michael Heerdegen
  2017-10-27 16:01   ` Nicolas Petton
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2017-10-27 14:08 UTC (permalink / raw)
  To: 28990; +Cc: Nicolas Petton, Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 340 bytes --]

Michael Heerdegen <michael_heerdegen@web.de> writes:

> #+begin_src emacs-lisp
> (defun my-thunk-test ()
>   (thunk-force (thunk-delay (+ 1 2))))
> #+end_src
>
> This compiles ok, but executing (my-thunk-test) without lexbind enabled
> gives you a meaningless error like "void-variable: forced".

Nicolas, Stefan - ok to fix it like that?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-Fix-bug-28990.patch --]
[-- Type: text/x-diff, Size: 748 bytes --]

From 45fe6b1bc9573257e59842283fd7da36d760c524 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Thu, 26 Oct 2017 12:57:55 +0200
Subject: [PATCH] WIP: Fix bug#28990

---
 lisp/emacs-lisp/thunk.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el
index bb6d277c27..6dc892c44b 100644
--- a/lisp/emacs-lisp/thunk.el
+++ b/lisp/emacs-lisp/thunk.el
@@ -44,9 +44,12 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-macs))
+
 (defmacro thunk-delay (&rest body)
   "Delay the evaluation of BODY."
   (declare (debug t))
+  (cl-assert lexical-binding)
   (let ((forced (make-symbol "forced"))
         (val (make-symbol "val")))
     `(let (,forced ,val)
-- 
2.14.2


[-- Attachment #3: Type: text/plain, Size: 131 bytes --]


I would additionally add a sentence to "thunk.el"'s header saying that
creating thunks requires lexical binding.


TIA,

Michael.

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#28990: 27.0.50; thunk-delay: running expansion also requires lexical-binding
  2017-10-27 14:08 ` Michael Heerdegen
@ 2017-10-27 16:01   ` Nicolas Petton
  2017-11-01 14:08     ` Michael Heerdegen
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Petton @ 2017-10-27 16:01 UTC (permalink / raw)
  To: Michael Heerdegen, 28990; +Cc: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 286 bytes --]

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Nicolas, Stefan - ok to fix it like that?

Yes, that's fine with me.

> I would additionally add a sentence to "thunk.el"'s header saying that
> creating thunks requires lexical binding.

That's a good idea, thanks.

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#28990: 27.0.50; thunk-delay: running expansion also requires lexical-binding
  2017-10-27 16:01   ` Nicolas Petton
@ 2017-11-01 14:08     ` Michael Heerdegen
  2017-11-01 14:48       ` Nicolas Petton
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2017-11-01 14:08 UTC (permalink / raw)
  To: Nicolas Petton; +Cc: 28990-done, Stefan Monnier

Nicolas Petton <nicolas@petton.fr> writes:

> > Nicolas, Stefan - ok to fix it like that?
>
> Yes, that's fine with me.
>
> > I would additionally add a sentence to "thunk.el"'s header saying that
> > creating thunks requires lexical binding.
>
> That's a good idea, thanks.

Done in bbb85eff49.

Michael.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#28990: 27.0.50; thunk-delay: running expansion also requires lexical-binding
  2017-11-01 14:08     ` Michael Heerdegen
@ 2017-11-01 14:48       ` Nicolas Petton
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Petton @ 2017-11-01 14:48 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 28990-done, Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 109 bytes --]

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Done in bbb85eff49.

Great, thank you.

Cheers,
Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-11-01 14:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25 13:47 bug#28990: 27.0.50; thunk-delay: running expansion also requires lexical-binding Michael Heerdegen
2017-10-27 14:08 ` Michael Heerdegen
2017-10-27 16:01   ` Nicolas Petton
2017-11-01 14:08     ` Michael Heerdegen
2017-11-01 14:48       ` Nicolas Petton

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.