unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
       [not found] ` <20180827155309.D5C18209C1@vcs0.savannah.gnu.org>
@ 2018-08-29 13:51   ` Michael Albinus
  2018-08-31  0:57     ` Gemini Lasswell
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2018-08-29 13:51 UTC (permalink / raw)
  To: emacs-devel; +Cc: Gemini Lasswell

gazally@runbox.com (Gemini Lasswell) writes:

Hi,

> branch: scratch/list-threads
> commit 833a2d41d07e3aa673ec5ab6f1d8ad1945bc5d0a
> Author: Gemini Lasswell <gazally@runbox.com>
> Commit: Gemini Lasswell <gazally@runbox.com>
>
>     Make lisp/thread.el the new home for thread-related Lisp functions
>     
>     * lisp/emacs-lisp/thread-list.el: Remove.
>     * lisp/emacs-lisp/thread.el: New file.

[...]

> -(provide 'thread-list)
> -;;; thread-list.el ends here
> +(provide 'thread)
> +;;; thread.el ends here

We have now src/thread.c and lisp/emacs-lisp/thread.el. The former
provides the feature `threads' (if Emacs is compiles with thread
support), the latter the feature `thread'.

Confusing.

Best regards, Michael.



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-29 13:51   ` scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions Michael Albinus
@ 2018-08-31  0:57     ` Gemini Lasswell
  2018-08-31  7:23       ` Michael Albinus
  0 siblings, 1 reply; 14+ messages in thread
From: Gemini Lasswell @ 2018-08-31  0:57 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

Michael Albinus <michael.albinus@gmx.de> writes:

> We have now src/thread.c and lisp/emacs-lisp/thread.el. The former
> provides the feature `threads' (if Emacs is compiles with thread
> support), the latter the feature `thread'.
>
> Confusing.

Hi Michael,

Other pairs of C and Lisp files share the same name without confusion,
so the confusing bit is the feature `threads' that thread.c provides.

That made me wonder why thread.c needs to provide `threads', so I looked
at the history of that file and found that you were the one who added it
(3744fda5fa), apparently in order to be able to skip tests if Emacs is
built --without-threads.

It seems to me that (bound-and-true-p main-thread) would work as a
substitute for (featurep 'threads) in the skip-unless forms in the
thread tests.  Can you think of a reason why it wouldn't?

Gemini




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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31  0:57     ` Gemini Lasswell
@ 2018-08-31  7:23       ` Michael Albinus
  2018-08-31 13:19         ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2018-08-31  7:23 UTC (permalink / raw)
  To: Gemini Lasswell; +Cc: emacs-devel

Gemini Lasswell <gazally@runbox.com> writes:

> Hi Michael,

Hi Gemini,

> That made me wonder why thread.c needs to provide `threads', so I looked
> at the history of that file and found that you were the one who added it
> (3744fda5fa), apparently in order to be able to skip tests if Emacs is
> built --without-threads.

Yes, but not only for skipping tests. Everybody who implements something
based on threads shall have a simple mean to see, whether thread support
is configured for Emacs.

> It seems to me that (bound-and-true-p main-thread) would work as a
> substitute for (featurep 'threads) in the skip-unless forms in the
> thread tests.  Can you think of a reason why it wouldn't?

It would work, of course. But I'm a finicky German :-) `featurep' is the
default way in Emacs to check, whether a feature exist, so I've done it
this way.

Maybe we could do something similar to D-Bus support in Emacs: in
src/dbusbind.c the feature `dbusbind' is provided, and in dbus.el there
is the feature `dbus'. The former allows you to check, whether D-Bus
support has been configured for Emacs.

So we might provide the feature `threads-supported' or similar in
src/thread.c. WDYT?

> Gemini

Best regards, Michael.



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31  7:23       ` Michael Albinus
@ 2018-08-31 13:19         ` Stefan Monnier
  2018-08-31 13:41           ` Michael Albinus
                             ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Stefan Monnier @ 2018-08-31 13:19 UTC (permalink / raw)
  To: emacs-devel

> It would work, of course. But I'm a finicky German :-) `featurep' is the
> default way in Emacs to check, whether a feature exist, so I've done it
> this way.

Actually, fboundp is a much more common way to perform such tests,
especially since it can silence some warnings at the same occasion.
(featurep 'xemacs) is an important exception, tho.

> So we might provide the feature `threads-supported' or similar in
> src/thread.c. WDYT?

What's wrong with (fboundp 'make-thread)?


        Stefan




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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31 13:19         ` Stefan Monnier
@ 2018-08-31 13:41           ` Michael Albinus
  2018-08-31 15:16             ` Stefan Monnier
  2018-08-31 15:07           ` Eli Zaretskii
  2018-09-03 10:08           ` Michael Albinus
  2 siblings, 1 reply; 14+ messages in thread
From: Michael Albinus @ 2018-08-31 13:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Actually, fboundp is a much more common way to perform such tests,
> especially since it can silence some warnings at the same occasion.

If we want to discourage the use of featurep, it shall be documented.
I, for example, regard it as natural way to test compatibility.

> (featurep 'xemacs) is an important exception, tho.

This test is not relevant anymore, isn't it?

> What's wrong with (fboundp 'make-thread)?

It returns t already for Emacs 26. If we go this way, (bound-and-true-p
main-thread) would be the better choice, as proposed by Gemini.

>         Stefan

Best regards, Michael.



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31 13:19         ` Stefan Monnier
  2018-08-31 13:41           ` Michael Albinus
@ 2018-08-31 15:07           ` Eli Zaretskii
  2018-09-03 13:14             ` Stefan Monnier
  2018-09-05 16:49             ` Gemini Lasswell
  2018-09-03 10:08           ` Michael Albinus
  2 siblings, 2 replies; 14+ messages in thread
From: Eli Zaretskii @ 2018-08-31 15:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Fri, 31 Aug 2018 09:19:58 -0400
> 
> What's wrong with (fboundp 'make-thread)?

That (AFAIK) it returns non-nil even when threads are not available?



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31 13:41           ` Michael Albinus
@ 2018-08-31 15:16             ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2018-08-31 15:16 UTC (permalink / raw)
  To: emacs-devel

>> Actually, fboundp is a much more common way to perform such tests,
>> especially since it can silence some warnings at the same occasion.
> If we want to discourage the use of featurep, it shall be documented.

I did not mean this to discourage its use.


        Stefan




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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31 13:19         ` Stefan Monnier
  2018-08-31 13:41           ` Michael Albinus
  2018-08-31 15:07           ` Eli Zaretskii
@ 2018-09-03 10:08           ` Michael Albinus
  2 siblings, 0 replies; 14+ messages in thread
From: Michael Albinus @ 2018-09-03 10:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> It would work, of course. But I'm a finicky German :-) `featurep' is the
>> default way in Emacs to check, whether a feature exist, so I've done it
>> this way.
>
> Actually, fboundp is a much more common way to perform such tests,
> especially since it can silence some warnings at the same occasion.
> (featurep 'xemacs) is an important exception, tho.

Currently, we have `features', which gives us the feature symbols of
loaded packages. What we would need are the configured featurea of
Emacs. What about this:

--8<---------------cut here---------------start------------->8---
(defconst configured-features
  (mapcar
    (lambda (feat) (intern (downcase feat)))
    (split-string system-configuration-features))
  "A list of symbols which are the configured features of the executing Emacs.")

(defun configured-feature-p (feature)
  "Return t if Emacs is configured with FEATURE."
  (and (member feature configured-features) t))
--8<---------------cut here---------------end--------------->8---

I could use then (configured-feature-p 'threads) in order to know
whether Emacs has been configured --with-threads, explicitly or implicitly.

>         Stefan

Best regards, Michael.



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31 15:07           ` Eli Zaretskii
@ 2018-09-03 13:14             ` Stefan Monnier
  2018-09-03 14:15               ` Michael Albinus
  2018-09-03 15:07               ` Eli Zaretskii
  2018-09-05 16:49             ` Gemini Lasswell
  1 sibling, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2018-09-03 13:14 UTC (permalink / raw)
  To: emacs-devel

>> What's wrong with (fboundp 'make-thread)?
> That (AFAIK) it returns non-nil even when threads are not available?

What is the reason for this?

Is it because we want to lazily try to load the relevant shared
library, so we don't know before the first call whether that shared
library is actually available?

> I could use then (configured-feature-p 'threads) in order to know
> whether Emacs has been configured --with-threads, explicitly or implicitly.

What if Emacs was configured --with-threads but at run-time the shared
lib is not available?
Maybe instead of

    (fboundp 'make-thread)

the better choice is

    (progn (ignore-errors (make-thread #'ignore)) t)

?


        Stefan




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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-09-03 13:14             ` Stefan Monnier
@ 2018-09-03 14:15               ` Michael Albinus
  2018-09-03 15:07               ` Eli Zaretskii
  1 sibling, 0 replies; 14+ messages in thread
From: Michael Albinus @ 2018-09-03 14:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I could use then (configured-feature-p 'threads) in order to know
>> whether Emacs has been configured --with-threads, explicitly or implicitly.
>
> What if Emacs was configured --with-threads but at run-time the shared
> lib is not available?

It shall crash. That's what other programs do, too.

> Maybe instead of
>
>     (fboundp 'make-thread)
>
> the better choice is
>
>     (progn (ignore-errors (make-thread #'ignore)) t)
>
> ?

Too complicate. And, as said already, make-thread is not the function
I'm interested in. It exists in Emacs 26, and I need further threads
functionality introduced in Emacs 27.

>         Stefan

Best regards, Michael.



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-09-03 13:14             ` Stefan Monnier
  2018-09-03 14:15               ` Michael Albinus
@ 2018-09-03 15:07               ` Eli Zaretskii
  2018-09-03 15:17                 ` Stefan Monnier
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2018-09-03 15:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Mon, 03 Sep 2018 09:14:13 -0400
> 
> >> What's wrong with (fboundp 'make-thread)?
> > That (AFAIK) it returns non-nil even when threads are not available?
> 
> What is the reason for this?

AFAIR, that was how Tom wrote the code in the first place.  It makes
the configury slightly less complicated, and makes extending the
low-level support to other threading libraries slightly easier.  Not
very important reasons, but then we do have other features that just
do nothing useful on platforms where they cannot be supported.

> Is it because we want to lazily try to load the relevant shared
> library, so we don't know before the first call whether that shared
> library is actually available?

No.  AFAIK, all platforms that support threads either don't need any
library, or load it right at the beginning.



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-09-03 15:07               ` Eli Zaretskii
@ 2018-09-03 15:17                 ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2018-09-03 15:17 UTC (permalink / raw)
  To: emacs-devel

>> >> What's wrong with (fboundp 'make-thread)?
>> > That (AFAIK) it returns non-nil even when threads are not available?
>> What is the reason for this?
> AFAIR, that was how Tom wrote the code in the first place.  It makes
> the configury slightly less complicated, and makes extending the
> low-level support to other threading libraries slightly easier.  Not
> very important reasons, but then we do have other features that just
> do nothing useful on platforms where they cannot be supported.

Hmm... I see.  That's too bad: (fboundp 'make-thread) seems like the
most natural way to check for availability of threading.

> No.  AFAIK, all platforms that support threads either don't need any
> library, or load it right at the beginning.

That was my impression,


        Stefan




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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-08-31 15:07           ` Eli Zaretskii
  2018-09-03 13:14             ` Stefan Monnier
@ 2018-09-05 16:49             ` Gemini Lasswell
  2018-09-05 17:48               ` Eli Zaretskii
  1 sibling, 1 reply; 14+ messages in thread
From: Gemini Lasswell @ 2018-09-05 16:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Date: Fri, 31 Aug 2018 09:19:58 -0400
>> 
>> What's wrong with (fboundp 'make-thread)?
>
> That (AFAIK) it returns non-nil even when threads are not available?

I just built Emacs configured --without-threads, and
(fboundp 'make-thread) returns nil.

On inspection of thread.c, the only Lisp symbols it creates if
THREADS_ENABLED is not defined are:

threadp
mutexp
condition-variable-p
main-thread



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

* Re: scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions
  2018-09-05 16:49             ` Gemini Lasswell
@ 2018-09-05 17:48               ` Eli Zaretskii
  0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2018-09-05 17:48 UTC (permalink / raw)
  To: Gemini Lasswell; +Cc: monnier, emacs-devel

> From: Gemini Lasswell <gazally@runbox.com>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,  emacs-devel@gnu.org
> Date: Wed, 05 Sep 2018 09:49:45 -0700
> 
> >> What's wrong with (fboundp 'make-thread)?
> >
> > That (AFAIK) it returns non-nil even when threads are not available?
> 
> I just built Emacs configured --without-threads, and
> (fboundp 'make-thread) returns nil.

Hmmm?...  Oh, yes: we don't call defsubr on the functions, although
the code is defined.  Somewhat silly, I'd say.



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

end of thread, other threads:[~2018-09-05 17:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180827155307.16925.11045@vcs0.savannah.gnu.org>
     [not found] ` <20180827155309.D5C18209C1@vcs0.savannah.gnu.org>
2018-08-29 13:51   ` scratch/list-threads 833a2d4 2/9: Make lisp/thread.el the new home for thread-related Lisp functions Michael Albinus
2018-08-31  0:57     ` Gemini Lasswell
2018-08-31  7:23       ` Michael Albinus
2018-08-31 13:19         ` Stefan Monnier
2018-08-31 13:41           ` Michael Albinus
2018-08-31 15:16             ` Stefan Monnier
2018-08-31 15:07           ` Eli Zaretskii
2018-09-03 13:14             ` Stefan Monnier
2018-09-03 14:15               ` Michael Albinus
2018-09-03 15:07               ` Eli Zaretskii
2018-09-03 15:17                 ` Stefan Monnier
2018-09-05 16:49             ` Gemini Lasswell
2018-09-05 17:48               ` Eli Zaretskii
2018-09-03 10:08           ` Michael Albinus

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).