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

2024-06-21 Thread Mattias Andrée
On Fri, 21 Jun 2024 23:29:29 +0200 Storkman wrote: > On Fri, Jun 21, 2024 at 10:12:15PM +0200, Mattias Andrée wrote: > > On Fri, 21 Jun 2024 21:14:19 +0200 > > Markus Wichmann wrote: > > > > > Am Thu, Jun 20, 2024 at 11:53:45PM +0200 schrieb Страхиња Радић: > > > > Given that, why complicat

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

2024-06-21 Thread stefan11111
În 22 iunie 2024 00:10:52 EEST, "Страхиња Радић" a scris: >Дана 24/06/21 09:14PM, Markus Wichmann написа: >> Isn't it all about familiarity in the end? Or can you articulate what >> parts of C11 and C23 you find objectionable? > >Just a few examples: > >- C11: bounds checking interfaces (now e

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

2024-06-21 Thread Storkman
On Fri, Jun 21, 2024 at 10:12:15PM +0200, Mattias Andrée wrote: > On Fri, 21 Jun 2024 21:14:19 +0200 > Markus Wichmann wrote: > > > Am Thu, Jun 20, 2024 at 11:53:45PM +0200 schrieb Страхиња Радић: > > > Given that, why complicate code by introducing a separate, superfluous, > > > type? > > > >

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

2024-06-21 Thread Страхиња Радић
Дана 24/06/21 09:14PM, Markus Wichmann написа: > Let me offer a counterpoint: Expressiveness. If I make a function return > a bool, then everyone from the world's worst junior dev to Ken Thompson > himself will be able to see at the very first glance that the function > is returning a boolean value

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

2024-06-21 Thread Mattias Andrée
On Fri, 21 Jun 2024 21:14:19 +0200 Markus Wichmann wrote: > Am Thu, Jun 20, 2024 at 11:53:45PM +0200 schrieb Страхиња Радић: > > Given that, why complicate code by introducing a separate, superfluous, > > type? > > Let me offer a counterpoint: Expressiveness. If I make a function return > a bo

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

2024-06-21 Thread Markus Wichmann
Am Thu, Jun 20, 2024 at 11:53:45PM +0200 schrieb Страхиња Радић: > Given that, why complicate code by introducing a separate, superfluous, > type? Let me offer a counterpoint: Expressiveness. If I make a function return a bool, then everyone from the world's worst junior dev to Ken Thompson himsel

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

2024-06-20 Thread Страхиња Радић
Дана 24/06/20 10:24PM, sewn написа: > Sure, but why? It is part of the suckless coding style. Since st is a suckless project, it follows the suckless coding style. * * * I can't speak for those who wrote the suckless coding standard, but as a bystander, I can give this observation. If the que

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

2024-06-20 Thread sewn
On 2024-06-15 22:06, Страхиња Радић wrote: Дана 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 Boole

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

2024-06-16 Thread Markus Wichmann
Am Sat, Jun 15, 2024 at 06:10:50PM +0200 schrieb Vincent Lefevre: > IMHO, this has been poorly designed. 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 portabi

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