Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread NRK
> There should have been a macro taking a parameter N (an integer > constant expression), where the type would have been valid for any N > up to the maximum width (thus at least 64). For portability, the > existence of the macro could have also been tested with #ifdef, > allowing a fallback. I don

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Mattias Andrée
On Sat, 15 Jun 2024 16:16:14 +0200 Mattias Andrée wrote: > You will save between 0 and 3 bytes on common platforms, > and those 3− bytes will probably be allocated and wasted anyway. > Is it worth it? > > It's absolutely better than _Bool, but I don't think there > is any point in using char ove

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Страхиња Радић
Дана 24/06/15 11:54AM, Zac написа: > I'm curious why you use ints though. Because bools are 31 bits smaller than > ints, which is 31 bits of memory saved. Not that 31 bits is very much, but >still... https://suckless.org/coding_style/ > Tests and Boolean Values > > * Do not use C99 bool types (

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Vincent Lefevre
On 2024-06-15 16:24:38 +0200, Mattias Andrée wrote: > No, you should use [u]int_least1_t, except that probably doesn't > exist, So, you must not use it. :) On the opposite, int_least8_t is a *required* type in ISO C99+. That's why I've proposed it. > I think C actually should add some what to sp

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Mattias Andrée
No, you should use [u]int_least1_t, except that probably doesn't exist, so char is best as it is per definition the most narrow type, and if the signness is important you can specify it. I think C actually should add some what to specify [u]int_{least,fast}N_t for arbitrary N. It could be simple a

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Mattias Andrée
You will save between 0 and 3 bytes on common platforms, and those 3− bytes will probably be allocated and wasted anyway. Is it worth it? It's absolutely better than _Bool, but I don't think there is any point in using char over int. All common operations (this may exclude division and modulo) sup

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Vincent Lefevre
On 2024-06-15 17:05:27 +0300, stefan1 wrote: > What about using char's then? char may be signed or unsigned. I would suggest unsigned char or signed char, or better, (u)int_least8_t. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog:

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread stefan11111
What about using char's then? În 15 iunie 2024 15:36:16 EEST, "Mattias Andrée" a scris: >I have some general issues with _Bool: > >Arithmetic or bitwise operations on _Bool is subject to type promotion >making them rather pointless. > >With also be a problem if they were not, as you than couldn't

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Mattias Andrée
I have some general issues with _Bool: Arithmetic or bitwise operations on _Bool is subject to type promotion making them rather pointless. With also be a problem if they were not, as you than couldn't sum of _Bool's to find how many were set (commonly this we be to detect if more than 1 was set)

Re: [dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Pontus Stenetorp
On Sat 15 Jun 2024, Zac wrote: > > In a number of spots in dwm and st I've seen the use of integers as booleans. > e.g. > - dwm.c line 95, 140, 1870 > - drw.c line 252 > - st.c line 44, 48 > > That's not an extensive list; just some examples. > > I'm curious why you use ints though. Because boo

[dev] [dwm][st] why use ints over bools?

2024-06-15 Thread Zac
In a number of spots in dwm and st I've seen the use of integers as booleans. e.g. - dwm.c line 95, 140, 1870 - drw.c line 252 - st.c line 44, 48 That's not an extensive list; just some examples. I'm curious why you use ints though. Because bools are 31 bits smaller than ints, which is 31 bits