Skip to contentSkip to conversation

C++: Convert the kernel to C++

PATCH Alexey Dobriyan 3 participants 4 messages Jan 11, 2024

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

SFINAE giving inscrutable errors is why I'm saying C++20, since "concept" means you can get usable error messages.

I'd say concepts are irrelevant for the kernel where standard library is tightly controlled by the same people who write rest of the kernel and no external users.

static_assert() is all you need.

#1 lore raw
Quoted 9 lines · Alexey Dobriyan
Quoted 3 lines

SFINAE giving inscrutable errors is why I'm saying C++20, since "concept" means you can get usable error messages.

I'd say concepts are irrelevant for the kernel where standard library is tightly controlled by the same people who write rest of the kernel and no external users.

static_assert() is all you need.

We have external users all the time, though. People who write external modules or new modules would fall in that classification. Why should it be harder for them?

Signature · 1 line
真実はいつも一つ!/ Always, there's only one truth!
#2 lore raw
Quoted 9 lines · Neal Gompa
Quoted 8 lines · Alexey Dobriyan
Quoted 3 lines

SFINAE giving inscrutable errors is why I'm saying C++20, since "concept" means you can get usable error messages.

I'd say concepts are irrelevant for the kernel where standard library is tightly controlled by the same people who write rest of the kernel and no external users.

Quoted 5 lines
Quoted 1 line

static_assert() is all you need.

We have external users all the time, though. People who write external modules or new modules would fall in that classification. Why should it be harder for them?

static_assert gives filename:line which clearly points to the source of an error.

Concepts are SFINAE replacement but if there is little SFINAE there will be little concepts too.

Another quite silly thing with concepts (and with noexcept propagation) is that programmer has to write an implementation then chop control flow and put everything else into the requires. And then to keep both in sync.

This is an example from cppreference:

	template<typename T>
		requires Addable<T>
	T
	add(T a, T b)
	{
		return a + b;
	}

Guess what Addable<> is?

They are kind of nice for simple things:

	template<typename It>
	concept MinimalIterator = requires(It it) { ++it; *it; it++; };
#3 lore raw
In reply to Neal Gompa
Quoted 9 lines · Neal Gompa
Quoted 8 lines · Alexey Dobriyan
Quoted 3 lines

SFINAE giving inscrutable errors is why I'm saying C++20, since "concept" means you can get usable error messages.

I'd say concepts are irrelevant for the kernel where standard library is tightly controlled by the same people who write rest of the kernel and no external users.

Quoted 5 lines
Quoted 1 line

static_assert() is all you need.

We have external users all the time, though. People who write external modules or new modules would fall in that classification. Why should it be harder for them?

I guess, I misunderstand something.

But WRT to the term 'external module' I have some comment.

My personal opinion is somewhat reflected in following article:

https://www.linuxfoundation.org/blog/blog/the-people-who-support-linux-snowden-revelations-spur-engineers-open-source-donation
(The People Who Support Linux: Snowden Revelations Spur Engineer's Open Source Donation) [The Linux Foundation | 18 December 2013]

„“The public needs fully open source OSes, where experts can review the whole code, to minimize the risk of hidden backdoors,” said Kies.“

Thinking more about this.

What exactly was the reason to allow Rust in the kernel?

What exactly is the reason to allow C++ in the kernel?

Besides, I think in general that complexity can be destructive -- even in a world without bad actors.

Quoted 2 lines
Signature · 1 line
真実はいつも一つ!/ Always, there's only one truth!