Sujet : Re: technology discussion → does the world need a "new" C ?
De : chris.m.thomasson.1 (at) *nospam* gmail.com (Chris M. Thomasson)
Groupes : comp.lang.cDate : 11. Jul 2024, 20:44:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6pcmg$2jl67$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Mozilla Thunderbird
On 7/11/2024 6:50 AM, bart wrote:
On 11/07/2024 03:51, Lawrence D'Oliveiro wrote:
On Wed, 10 Jul 2024 03:16:18 -0400, James Kuyper wrote:
>
On 7/9/24 20:57, Lawrence D'Oliveiro wrote:
>
On Sat, 6 Jul 2024 21:34:29 -0400, James Kuyper wrote:
>
On many platforms, if _Alignof(type) is less than the word size, then
a C pointer to that type is implemented as the combination of the
machine address of the correct word, combined with an offset within
that word of the first byte of that object.
>
Which is a terrific idea, except it cannot be carried to its logical
conclusion (addressing of arbitrarily-aligned dynamically-defined
bitfields) because of the requirement in the C spec that the size of a
“byte” be at least 8 bits.
>
I will grant you that I failed to mention the fact that this is a
feasible way of implementing C only on platforms with a word size of 16
bits or longer.
>
Don’t you think C needs a better way of handling bitfields than shift-and-
mask?
Yes. But because it's not hard for a million programmers to each create their own macros like GETBIT and SETBIT, that's not going to happen.
Although bit operations are unusual in other languages too.
[...]
Fwiw, the last time I really used them was for special lock/wait-free algorithms. Stealing bits from pointers and aligning and passing structures on special boundaries.