* 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 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
* 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