unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Thread return value
@ 2023-11-05  8:57 Manuel Giraud via Emacs development discussions.
  2023-11-05  9:07 ` Helmut Eller
  2023-11-05  9:48 ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Manuel Giraud via Emacs development discussions. @ 2023-11-05  8:57 UTC (permalink / raw)
  To: emacs-devel

Hi,

Is there a way to retrieve an Emacs thread's implicit return value?  In
the simple example below, it would be to get the boolean value computed
by the thread 'my-flip' after its death:

--8<---------------cut here---------------start------------->8---
(defun coin ()
  (evenp (random 100)))

(setq my-flip (make-thread #'coin))
--8<---------------cut here---------------end--------------->8---

I don't need a solution where I can 'setq' a global variable into
'coin'.  Consider that 'coin' is immutable (or written by someone else
for other purpose).

If this is not currently possible, do you think it would be a hard thing
to do in "thread.el" or "thread.c"?

Best regards,
-- 
Manuel Giraud



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

* Re: Thread return value
  2023-11-05  8:57 Thread return value Manuel Giraud via Emacs development discussions.
@ 2023-11-05  9:07 ` Helmut Eller
  2023-11-05 10:07   ` Manuel Giraud via Emacs development discussions.
  2023-11-05  9:48 ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Helmut Eller @ 2023-11-05  9:07 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-devel

On Sun, Nov 05 2023, Manuel Giraud via "Emacs development discussions." wrote:

> Hi,
>
> Is there a way to retrieve an Emacs thread's implicit return value?

thread-join would probably work.

Helmut



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

* Re: Thread return value
  2023-11-05  8:57 Thread return value Manuel Giraud via Emacs development discussions.
  2023-11-05  9:07 ` Helmut Eller
@ 2023-11-05  9:48 ` Eli Zaretskii
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2023-11-05  9:48 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-devel

> Date: Sun, 05 Nov 2023 09:57:40 +0100
> From:  Manuel Giraud via "Emacs development discussions." <emacs-devel@gnu.org>
> 
> Is there a way to retrieve an Emacs thread's implicit return value?

Yes, by calling thread-join.



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

* Re: Thread return value
  2023-11-05  9:07 ` Helmut Eller
@ 2023-11-05 10:07   ` Manuel Giraud via Emacs development discussions.
  2023-11-05 10:13     ` Manuel Giraud via Emacs development discussions.
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Giraud via Emacs development discussions. @ 2023-11-05 10:07 UTC (permalink / raw)
  To: Helmut Eller; +Cc: emacs-devel

Helmut Eller <eller.helmut@gmail.com> writes:

> On Sun, Nov 05 2023, Manuel Giraud via "Emacs development discussions." wrote:
>
>> Hi,
>>
>> Is there a way to retrieve an Emacs thread's implicit return value?
>
> thread-join would probably work.

Thanks!  It was simple as that 😅.  It was not clear from the elisp info
page.
-- 
Manuel Giraud



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

* Re: Thread return value
  2023-11-05 10:07   ` Manuel Giraud via Emacs development discussions.
@ 2023-11-05 10:13     ` Manuel Giraud via Emacs development discussions.
  0 siblings, 0 replies; 5+ messages in thread
From: Manuel Giraud via Emacs development discussions. @ 2023-11-05 10:13 UTC (permalink / raw)
  To: Helmut Eller; +Cc: emacs-devel

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Thanks!  It was simple as that 😅.  It was not clear from the elisp info
> page.

I guess I should learn to read : "It returns the result of the THREAD function."
-- 
Manuel Giraud



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

end of thread, other threads:[~2023-11-05 10:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-05  8:57 Thread return value Manuel Giraud via Emacs development discussions.
2023-11-05  9:07 ` Helmut Eller
2023-11-05 10:07   ` Manuel Giraud via Emacs development discussions.
2023-11-05 10:13     ` Manuel Giraud via Emacs development discussions.
2023-11-05  9:48 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).